Comparing version 1.7.2 to 1.8.0
@@ -32,4 +32,2 @@ (function (exports) { | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
function addClass(selector, cls) { | ||
@@ -43,15 +41,9 @@ if (Array.isArray(selector)) { | ||
if (els.length) { | ||
var _ret = function () { | ||
var clsArray = [].concat(cls); | ||
els.forEach(function (el) { | ||
clsArray.forEach(function (item) { | ||
el.classList.add(item); | ||
}); | ||
var clsArray = [].concat(cls); | ||
els.forEach(function (el) { | ||
clsArray.forEach(function (item) { | ||
el.classList.add(item); | ||
}); | ||
return { | ||
v: els | ||
}; | ||
}(); | ||
if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v; | ||
}); | ||
return els; | ||
} | ||
@@ -115,2 +107,54 @@ } | ||
var NativeCustomEvent = window.CustomEvent; | ||
// | ||
// Check for the usage of native support for CustomEvents which is lacking | ||
// completely on IE. | ||
// | ||
function canIuseNativeCustom() { | ||
try { | ||
var p = new NativeCustomEvent('t', { | ||
detail: { | ||
a: 'b' | ||
} | ||
}); | ||
return p.type === 't' && p.detail.a === 'b'; | ||
} catch (e) { | ||
return false; | ||
} | ||
} | ||
// Lousy polyfill for the Custom Event constructor for IE. | ||
var IECustomEvent = function CustomEvent(type, params) { | ||
var e = document.createEvent('CustomEvent'); | ||
if (params) { | ||
e.initCustomEvent(type, params.bubbles, params.cancelable, params.detail); | ||
} else { | ||
e.initCustomEvent(type, false, false, undefined); | ||
} | ||
return e; | ||
}; | ||
var DomassistCustomEvent = canIuseNativeCustom() ? NativeCustomEvent : IECustomEvent; | ||
function fire(selector, type, params) { | ||
if (Array.isArray(selector)) { | ||
return selector.forEach(function (item) { | ||
return fire(item, type, params); | ||
}); | ||
} | ||
var els = find(selector); | ||
if (els.length) { | ||
els.forEach(function (el) { | ||
var event = new DomassistCustomEvent(type, params); | ||
el.dispatchEvent(event); | ||
}); | ||
return els; | ||
} | ||
} | ||
function hasClass(selector, cls) { | ||
@@ -180,4 +224,2 @@ var el = findOne(selector); | ||
var _typeof$1 = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
function removeClass(selector, cls) { | ||
@@ -192,15 +234,9 @@ if (Array.isArray(selector)) { | ||
if (els.length) { | ||
var _ret = function () { | ||
var clsArray = [].concat(cls); | ||
els.forEach(function (el) { | ||
clsArray.forEach(function (item) { | ||
el.classList.remove(item); | ||
}); | ||
var clsArray = [].concat(cls); | ||
els.forEach(function (el) { | ||
clsArray.forEach(function (item) { | ||
el.classList.remove(item); | ||
}); | ||
return { | ||
v: els | ||
}; | ||
}(); | ||
if ((typeof _ret === 'undefined' ? 'undefined' : _typeof$1(_ret)) === "object") return _ret.v; | ||
}); | ||
return els; | ||
} | ||
@@ -411,2 +447,3 @@ } | ||
findOne: findOne, | ||
fire: fire, | ||
hasClass: hasClass, | ||
@@ -438,2 +475,3 @@ hide: hide, | ||
exports.findOne = findOne; | ||
exports.fire = fire; | ||
exports.hasClass = hasClass; | ||
@@ -440,0 +478,0 @@ exports.hide = hide; |
@@ -5,2 +5,3 @@ import addClass from './lib/addClass'; | ||
import findOne from './lib/findOne'; | ||
import fire from './lib/fire'; | ||
import hasClass from './lib/hasClass'; | ||
@@ -32,2 +33,3 @@ import hide from './lib/hide'; | ||
findOne, | ||
fire, | ||
hasClass, | ||
@@ -34,0 +36,0 @@ hide, |
@@ -5,2 +5,3 @@ export { default as addClass } from './lib/addClass'; | ||
export { default as findOne } from './lib/findOne'; | ||
export { default as fire } from './lib/fire'; | ||
export { default as hasClass } from './lib/hasClass'; | ||
@@ -7,0 +8,0 @@ export { default as hide } from './lib/hide'; |
{ | ||
"name": "domassist", | ||
"version": "1.7.2", | ||
"version": "1.8.0", | ||
"description": "Various dom helpers", | ||
@@ -9,3 +9,4 @@ "main": "dist/domassist.js", | ||
"start": "scriptkit", | ||
"test": "cat test/domassist.test.dist.js | tape-run --browser phantomjs --render tap-spec", | ||
"dev": "scriptkit dev", | ||
"test": "cat test/domassist.test.dist.js | tape-run --static . --browser phantomjs --render tap-spec", | ||
"prepublish": "scriptkit" | ||
@@ -30,6 +31,6 @@ }, | ||
"devDependencies": { | ||
"eslint-config-firstandthird": "^3.1.0", | ||
"eslint-config-firstandthird": "3.2.0", | ||
"eslint-plugin-import": "^2.1.0", | ||
"phantomjs-prebuilt": "^2.1.14", | ||
"scriptkit": "0.0.22", | ||
"scriptkit": "0.2.0", | ||
"static-server": "^2.0.3", | ||
@@ -50,9 +51,11 @@ "tap-spec": "^4.1.1", | ||
"scriptkit": { | ||
"files": { | ||
"dist/domassist.js": "domassist.js", | ||
"test/domassist.test.dist.js": "test/domassist.test.js" | ||
}, | ||
"scripts": { | ||
"commonjs": { | ||
"include": "node_modules/**" | ||
}, | ||
"files": { | ||
"dist/domassist.js": "domassist.js", | ||
"test/domassist.test.dist.js": "test/domassist.test.js" | ||
"babel": { | ||
"exclude": [ | ||
"node_modules/tape-rollup/*" | ||
] | ||
} | ||
@@ -59,0 +62,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
43
917
100920