made with esnextbin
Last active
October 24, 2016 08:57
-
-
Save aledoroshenko/41b36c78d52e9293b1ca9c911c6cf3e3 to your computer and use it in GitHub Desktop.
esnextbin sketch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>ESNextbin Sketch</title> | |
<!-- put additional styles and scripts here --> | |
</head> | |
<body> | |
<!-- put markup and other contents here --> | |
<div class="ncc-grid-block secondary-nac-block jstest1"></div> | |
<div class="ncc-grid-block secondary-nac-block jstest2"></div> | |
<div class="jstest3"></div> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import $ from 'jquery'; | |
import expect from 'expect'; | |
import _ from 'lodash'; | |
function needForceClear(element) { | |
var $element = $(element); | |
return _.some(_.map( | |
['ncc-grid-block', 'secondary-nav-block', 'customer-header']), | |
$element.hasClass.bind($element) | |
) | |
} | |
tests(); | |
function tests() { | |
var el1 = $('.jstest1').get(0); | |
var el2 = $('.jstest2'); | |
var el3 = $('.jstest3'); | |
expect(needForceClear(el1)).toBe(true); | |
expect(needForceClear(el2)).toBe(true); | |
expect(needForceClear(el3)).toBe(false); | |
expect(needForceClear(undefined)).toBe(false); | |
console.log('tests success') | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "esnextbin-sketch", | |
"version": "0.0.0", | |
"dependecies": { | |
"lodash": "~4.14.1", | |
"expect": "~1.20.2", | |
"jquery": "~3.1.1" | |
}, | |
"dependencies": { | |
"jquery": "3.1.1", | |
"expect": "1.20.2", | |
"lodash": "4.16.2" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var _jquery = require('jquery'); | |
var _jquery2 = _interopRequireDefault(_jquery); | |
var _expect = require('expect'); | |
var _expect2 = _interopRequireDefault(_expect); | |
var _lodash = require('lodash'); | |
var _lodash2 = _interopRequireDefault(_lodash); | |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | |
function needForceClear(element) { | |
var $element = (0, _jquery2.default)(element); | |
return _lodash2.default.some(_lodash2.default.map(['ncc-grid-block', 'secondary-nav-block', 'customer-header']), $element.hasClass.bind($element)); | |
} | |
tests(); | |
function tests() { | |
var el1 = (0, _jquery2.default)('.jstest1').get(0); | |
var el2 = (0, _jquery2.default)('.jstest2'); | |
var el3 = (0, _jquery2.default)('.jstest3'); | |
(0, _expect2.default)(needForceClear(el1)).toBe(true); | |
(0, _expect2.default)(needForceClear(el2)).toBe(true); | |
(0, _expect2.default)(needForceClear(el3)).toBe(false); | |
(0, _expect2.default)(needForceClear(undefined)).toBe(false); | |
console.log('tests success'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment