Comparing version 3.1.3 to 3.2.0
@@ -9,2 +9,10 @@ # Changelog | ||
## 3.2.0 | ||
* `FEAT`: add `assignStyle` utility | ||
## 3.1.3 | ||
* `FIX`: insource delegate-events ([#8](https://github.com/bpmn-io/min-dom/issues/8)) | ||
## 3.1.2 | ||
@@ -11,0 +19,0 @@ |
@@ -58,3 +58,3 @@ /** | ||
export function bind<CType extends Function>(el: EventTarget, type: string, fn: CType, capture?: boolean): CType; | ||
export function unbind<CType extends Function>(el: EventTarget , type: string, fn: CType, capture?: boolean): CType; | ||
export function unbind<CType extends Function>(el: EventTarget, type: string, fn: CType, capture?: boolean): CType; | ||
} | ||
@@ -74,1 +74,3 @@ | ||
export function remove(el: Element): void; | ||
export function assignStyle<E extends Element>(element: E, ...styleSources: object): E; |
/** | ||
* Flatten array, one level deep. | ||
* | ||
* @param {Array<?>} arr | ||
* | ||
* @return {Array<?>} | ||
*/ | ||
var nativeToString = Object.prototype.toString; | ||
var nativeHasOwnProperty = Object.prototype.hasOwnProperty; | ||
function isUndefined(obj) { | ||
return obj === undefined; | ||
} | ||
function isArray(obj) { | ||
return nativeToString.call(obj) === '[object Array]'; | ||
} | ||
/** | ||
* Return true, if target owns a property with the given key. | ||
* | ||
* @param {Object} target | ||
* @param {String} key | ||
* | ||
* @return {Boolean} | ||
*/ | ||
function has(target, key) { | ||
return nativeHasOwnProperty.call(target, key); | ||
} | ||
/** | ||
* Iterate over collection; returning something | ||
* (non-undefined) will stop iteration. | ||
* | ||
* @param {Array|Object} collection | ||
* @param {Function} iterator | ||
* | ||
* @return {Object} return result that stopped the iteration | ||
*/ | ||
function forEach(collection, iterator) { | ||
var val, result; | ||
if (isUndefined(collection)) { | ||
return; | ||
} | ||
var convertKey = isArray(collection) ? toNum : identity; | ||
for (var key in collection) { | ||
if (has(collection, key)) { | ||
val = collection[key]; | ||
result = iterator(val, convertKey(key)); | ||
if (result === false) { | ||
return val; | ||
} | ||
} | ||
} | ||
} | ||
function identity(arg) { | ||
return arg; | ||
} | ||
function toNum(arg) { | ||
return Number(arg); | ||
} | ||
/** | ||
* Assigns style attributes in a style-src compliant way. | ||
* | ||
* @param {Element} element | ||
* @param {...Object} styleSources | ||
* | ||
* @return {Element} the element | ||
*/ | ||
function assign$1(element) { | ||
var target = element.style; | ||
for (var _len = arguments.length, styleSources = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
styleSources[_key - 1] = arguments[_key]; | ||
} | ||
forEach(styleSources, function (style) { | ||
if (!style) { | ||
return; | ||
} | ||
forEach(style, function (value, key) { | ||
target[key] = value; | ||
}); | ||
}); | ||
return element; | ||
} | ||
/** | ||
* Set attribute `name` to `val`, or get attr `name`. | ||
@@ -287,5 +382,5 @@ * | ||
var bind = window.addEventListener ? 'addEventListener' : 'attachEvent', | ||
var bind$1 = window.addEventListener ? 'addEventListener' : 'attachEvent', | ||
unbind = window.removeEventListener ? 'removeEventListener' : 'detachEvent', | ||
prefix = bind !== 'addEventListener' ? 'on' : ''; | ||
prefix = bind$1 !== 'addEventListener' ? 'on' : ''; | ||
@@ -304,3 +399,3 @@ /** | ||
var bind_1 = function(el, type, fn, capture){ | ||
el[bind](prefix + type, fn, capture || false); | ||
el[bind$1](prefix + type, fn, capture || false); | ||
return fn; | ||
@@ -352,3 +447,3 @@ }; | ||
function bind$1(el, selector, type, fn, capture) { | ||
function bind$2(el, selector, type, fn, capture) { | ||
if (forceCaptureEvents.indexOf(type) !== -1) { | ||
@@ -385,3 +480,3 @@ capture = true; | ||
var delegate = { | ||
bind: bind$1, | ||
bind: bind$2, | ||
unbind: unbind$1 | ||
@@ -416,3 +511,3 @@ }; | ||
var map = { | ||
var map$1 = { | ||
legend: [1, '<fieldset>', '</fieldset>'], | ||
@@ -426,23 +521,23 @@ tr: [2, '<table><tbody>', '</tbody></table>'], | ||
map.td = | ||
map.th = [3, '<table><tbody><tr>', '</tr></tbody></table>']; | ||
map$1.td = | ||
map$1.th = [3, '<table><tbody><tr>', '</tr></tbody></table>']; | ||
map.option = | ||
map.optgroup = [1, '<select multiple="multiple">', '</select>']; | ||
map$1.option = | ||
map$1.optgroup = [1, '<select multiple="multiple">', '</select>']; | ||
map.thead = | ||
map.tbody = | ||
map.colgroup = | ||
map.caption = | ||
map.tfoot = [1, '<table>', '</table>']; | ||
map$1.thead = | ||
map$1.tbody = | ||
map$1.colgroup = | ||
map$1.caption = | ||
map$1.tfoot = [1, '<table>', '</table>']; | ||
map.polyline = | ||
map.ellipse = | ||
map.polygon = | ||
map.circle = | ||
map.text = | ||
map.line = | ||
map.path = | ||
map.rect = | ||
map.g = [1, '<svg xmlns="http://www.w3.org/2000/svg" version="1.1">','</svg>']; | ||
map$1.polyline = | ||
map$1.ellipse = | ||
map$1.polygon = | ||
map$1.circle = | ||
map$1.text = | ||
map$1.line = | ||
map$1.path = | ||
map$1.rect = | ||
map$1.g = [1, '<svg xmlns="http://www.w3.org/2000/svg" version="1.1">','</svg>']; | ||
@@ -482,3 +577,3 @@ /** | ||
// wrap map | ||
var wrap = map[tag] || map._default; | ||
var wrap = map$1[tag] || map$1._default; | ||
var depth = wrap[0]; | ||
@@ -521,2 +616,2 @@ var prefix = wrap[1]; | ||
export { attr, classes, clear, closest, delegate, domify, componentEvent as event, matchesSelector as matches, query, all as queryAll, remove }; | ||
export { assign$1 as assignStyle, attr, classes, clear, closest, delegate, domify, componentEvent as event, matchesSelector as matches, query, all as queryAll, remove }; |
@@ -6,2 +6,97 @@ 'use strict'; | ||
/** | ||
* Flatten array, one level deep. | ||
* | ||
* @param {Array<?>} arr | ||
* | ||
* @return {Array<?>} | ||
*/ | ||
var nativeToString = Object.prototype.toString; | ||
var nativeHasOwnProperty = Object.prototype.hasOwnProperty; | ||
function isUndefined(obj) { | ||
return obj === undefined; | ||
} | ||
function isArray(obj) { | ||
return nativeToString.call(obj) === '[object Array]'; | ||
} | ||
/** | ||
* Return true, if target owns a property with the given key. | ||
* | ||
* @param {Object} target | ||
* @param {String} key | ||
* | ||
* @return {Boolean} | ||
*/ | ||
function has(target, key) { | ||
return nativeHasOwnProperty.call(target, key); | ||
} | ||
/** | ||
* Iterate over collection; returning something | ||
* (non-undefined) will stop iteration. | ||
* | ||
* @param {Array|Object} collection | ||
* @param {Function} iterator | ||
* | ||
* @return {Object} return result that stopped the iteration | ||
*/ | ||
function forEach(collection, iterator) { | ||
var val, result; | ||
if (isUndefined(collection)) { | ||
return; | ||
} | ||
var convertKey = isArray(collection) ? toNum : identity; | ||
for (var key in collection) { | ||
if (has(collection, key)) { | ||
val = collection[key]; | ||
result = iterator(val, convertKey(key)); | ||
if (result === false) { | ||
return val; | ||
} | ||
} | ||
} | ||
} | ||
function identity(arg) { | ||
return arg; | ||
} | ||
function toNum(arg) { | ||
return Number(arg); | ||
} | ||
/** | ||
* Assigns style attributes in a style-src compliant way. | ||
* | ||
* @param {Element} element | ||
* @param {...Object} styleSources | ||
* | ||
* @return {Element} the element | ||
*/ | ||
function assign$1(element) { | ||
var target = element.style; | ||
for (var _len = arguments.length, styleSources = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
styleSources[_key - 1] = arguments[_key]; | ||
} | ||
forEach(styleSources, function (style) { | ||
if (!style) { | ||
return; | ||
} | ||
forEach(style, function (value, key) { | ||
target[key] = value; | ||
}); | ||
}); | ||
return element; | ||
} | ||
/** | ||
* Set attribute `name` to `val`, or get attr `name`. | ||
@@ -292,5 +387,5 @@ * | ||
var bind = window.addEventListener ? 'addEventListener' : 'attachEvent', | ||
var bind$1 = window.addEventListener ? 'addEventListener' : 'attachEvent', | ||
unbind = window.removeEventListener ? 'removeEventListener' : 'detachEvent', | ||
prefix = bind !== 'addEventListener' ? 'on' : ''; | ||
prefix = bind$1 !== 'addEventListener' ? 'on' : ''; | ||
@@ -309,3 +404,3 @@ /** | ||
var bind_1 = function(el, type, fn, capture){ | ||
el[bind](prefix + type, fn, capture || false); | ||
el[bind$1](prefix + type, fn, capture || false); | ||
return fn; | ||
@@ -357,3 +452,3 @@ }; | ||
function bind$1(el, selector, type, fn, capture) { | ||
function bind$2(el, selector, type, fn, capture) { | ||
if (forceCaptureEvents.indexOf(type) !== -1) { | ||
@@ -390,3 +485,3 @@ capture = true; | ||
var delegate = { | ||
bind: bind$1, | ||
bind: bind$2, | ||
unbind: unbind$1 | ||
@@ -421,3 +516,3 @@ }; | ||
var map = { | ||
var map$1 = { | ||
legend: [1, '<fieldset>', '</fieldset>'], | ||
@@ -431,23 +526,23 @@ tr: [2, '<table><tbody>', '</tbody></table>'], | ||
map.td = | ||
map.th = [3, '<table><tbody><tr>', '</tr></tbody></table>']; | ||
map$1.td = | ||
map$1.th = [3, '<table><tbody><tr>', '</tr></tbody></table>']; | ||
map.option = | ||
map.optgroup = [1, '<select multiple="multiple">', '</select>']; | ||
map$1.option = | ||
map$1.optgroup = [1, '<select multiple="multiple">', '</select>']; | ||
map.thead = | ||
map.tbody = | ||
map.colgroup = | ||
map.caption = | ||
map.tfoot = [1, '<table>', '</table>']; | ||
map$1.thead = | ||
map$1.tbody = | ||
map$1.colgroup = | ||
map$1.caption = | ||
map$1.tfoot = [1, '<table>', '</table>']; | ||
map.polyline = | ||
map.ellipse = | ||
map.polygon = | ||
map.circle = | ||
map.text = | ||
map.line = | ||
map.path = | ||
map.rect = | ||
map.g = [1, '<svg xmlns="http://www.w3.org/2000/svg" version="1.1">','</svg>']; | ||
map$1.polyline = | ||
map$1.ellipse = | ||
map$1.polygon = | ||
map$1.circle = | ||
map$1.text = | ||
map$1.line = | ||
map$1.path = | ||
map$1.rect = | ||
map$1.g = [1, '<svg xmlns="http://www.w3.org/2000/svg" version="1.1">','</svg>']; | ||
@@ -487,3 +582,3 @@ /** | ||
// wrap map | ||
var wrap = map[tag] || map._default; | ||
var wrap = map$1[tag] || map$1._default; | ||
var depth = wrap[0]; | ||
@@ -526,2 +621,3 @@ var prefix = wrap[1]; | ||
exports.assignStyle = assign$1; | ||
exports.attr = attr; | ||
@@ -528,0 +624,0 @@ exports.classes = classes; |
@@ -8,2 +8,97 @@ (function (global, factory) { | ||
/** | ||
* Flatten array, one level deep. | ||
* | ||
* @param {Array<?>} arr | ||
* | ||
* @return {Array<?>} | ||
*/ | ||
var nativeToString = Object.prototype.toString; | ||
var nativeHasOwnProperty = Object.prototype.hasOwnProperty; | ||
function isUndefined(obj) { | ||
return obj === undefined; | ||
} | ||
function isArray(obj) { | ||
return nativeToString.call(obj) === '[object Array]'; | ||
} | ||
/** | ||
* Return true, if target owns a property with the given key. | ||
* | ||
* @param {Object} target | ||
* @param {String} key | ||
* | ||
* @return {Boolean} | ||
*/ | ||
function has(target, key) { | ||
return nativeHasOwnProperty.call(target, key); | ||
} | ||
/** | ||
* Iterate over collection; returning something | ||
* (non-undefined) will stop iteration. | ||
* | ||
* @param {Array|Object} collection | ||
* @param {Function} iterator | ||
* | ||
* @return {Object} return result that stopped the iteration | ||
*/ | ||
function forEach(collection, iterator) { | ||
var val, result; | ||
if (isUndefined(collection)) { | ||
return; | ||
} | ||
var convertKey = isArray(collection) ? toNum : identity; | ||
for (var key in collection) { | ||
if (has(collection, key)) { | ||
val = collection[key]; | ||
result = iterator(val, convertKey(key)); | ||
if (result === false) { | ||
return val; | ||
} | ||
} | ||
} | ||
} | ||
function identity(arg) { | ||
return arg; | ||
} | ||
function toNum(arg) { | ||
return Number(arg); | ||
} | ||
/** | ||
* Assigns style attributes in a style-src compliant way. | ||
* | ||
* @param {Element} element | ||
* @param {...Object} styleSources | ||
* | ||
* @return {Element} the element | ||
*/ | ||
function assign$1(element) { | ||
var target = element.style; | ||
for (var _len = arguments.length, styleSources = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
styleSources[_key - 1] = arguments[_key]; | ||
} | ||
forEach(styleSources, function (style) { | ||
if (!style) { | ||
return; | ||
} | ||
forEach(style, function (value, key) { | ||
target[key] = value; | ||
}); | ||
}); | ||
return element; | ||
} | ||
/** | ||
* Set attribute `name` to `val`, or get attr `name`. | ||
@@ -294,5 +389,5 @@ * | ||
var bind = window.addEventListener ? 'addEventListener' : 'attachEvent', | ||
var bind$1 = window.addEventListener ? 'addEventListener' : 'attachEvent', | ||
unbind = window.removeEventListener ? 'removeEventListener' : 'detachEvent', | ||
prefix = bind !== 'addEventListener' ? 'on' : ''; | ||
prefix = bind$1 !== 'addEventListener' ? 'on' : ''; | ||
@@ -311,3 +406,3 @@ /** | ||
var bind_1 = function(el, type, fn, capture){ | ||
el[bind](prefix + type, fn, capture || false); | ||
el[bind$1](prefix + type, fn, capture || false); | ||
return fn; | ||
@@ -359,3 +454,3 @@ }; | ||
function bind$1(el, selector, type, fn, capture) { | ||
function bind$2(el, selector, type, fn, capture) { | ||
if (forceCaptureEvents.indexOf(type) !== -1) { | ||
@@ -392,3 +487,3 @@ capture = true; | ||
var delegate = { | ||
bind: bind$1, | ||
bind: bind$2, | ||
unbind: unbind$1 | ||
@@ -423,3 +518,3 @@ }; | ||
var map = { | ||
var map$1 = { | ||
legend: [1, '<fieldset>', '</fieldset>'], | ||
@@ -433,23 +528,23 @@ tr: [2, '<table><tbody>', '</tbody></table>'], | ||
map.td = | ||
map.th = [3, '<table><tbody><tr>', '</tr></tbody></table>']; | ||
map$1.td = | ||
map$1.th = [3, '<table><tbody><tr>', '</tr></tbody></table>']; | ||
map.option = | ||
map.optgroup = [1, '<select multiple="multiple">', '</select>']; | ||
map$1.option = | ||
map$1.optgroup = [1, '<select multiple="multiple">', '</select>']; | ||
map.thead = | ||
map.tbody = | ||
map.colgroup = | ||
map.caption = | ||
map.tfoot = [1, '<table>', '</table>']; | ||
map$1.thead = | ||
map$1.tbody = | ||
map$1.colgroup = | ||
map$1.caption = | ||
map$1.tfoot = [1, '<table>', '</table>']; | ||
map.polyline = | ||
map.ellipse = | ||
map.polygon = | ||
map.circle = | ||
map.text = | ||
map.line = | ||
map.path = | ||
map.rect = | ||
map.g = [1, '<svg xmlns="http://www.w3.org/2000/svg" version="1.1">','</svg>']; | ||
map$1.polyline = | ||
map$1.ellipse = | ||
map$1.polygon = | ||
map$1.circle = | ||
map$1.text = | ||
map$1.line = | ||
map$1.path = | ||
map$1.rect = | ||
map$1.g = [1, '<svg xmlns="http://www.w3.org/2000/svg" version="1.1">','</svg>']; | ||
@@ -489,3 +584,3 @@ /** | ||
// wrap map | ||
var wrap = map[tag] || map._default; | ||
var wrap = map$1[tag] || map$1._default; | ||
var depth = wrap[0]; | ||
@@ -528,2 +623,3 @@ var prefix = wrap[1]; | ||
exports.assignStyle = assign$1; | ||
exports.attr = attr; | ||
@@ -530,0 +626,0 @@ exports.classes = classes; |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.MinDom={})}(this,function(e){"use strict";function n(e,t){if(i)return e.indexOf(t);for(var r=0;r<e.length;++r)if(e[r]===t)return r;return-1}var i=[].indexOf,t=/\s+/,o=Object.prototype.toString;function r(e){if(!e||!e.nodeType)throw new Error("A DOM element reference is required");this.el=e,this.list=e.classList}r.prototype.add=function(e){if(this.list)return this.list.add(e),this;var t=this.array();return~n(t,e)||t.push(e),this.el.className=t.join(" "),this},r.prototype.remove=function(e){if("[object RegExp]"==o.call(e))return this.removeMatching(e);if(this.list)return this.list.remove(e),this;var t=this.array(),r=n(t,e);return~r&&t.splice(r,1),this.el.className=t.join(" "),this},r.prototype.removeMatching=function(e){for(var t=this.array(),r=0;r<t.length;r++)e.test(t[r])&&this.remove(t[r]);return this},r.prototype.toggle=function(e,t){return this.list?void 0!==t&&t===this.list.toggle(e,t)||this.list.toggle(e):void 0!==t?t?this.add(e):this.remove(e):this.has(e)?this.remove(e):this.add(e),this},r.prototype.array=function(){var e=(this.el.getAttribute("class")||"").replace(/^\s+|\s+$/g,"").split(t);return""===e[0]&&e.shift(),e},r.prototype.has=r.prototype.contains=function(e){return this.list?this.list.contains(e):!!~n(this.array(),e)};var l="undefined"!=typeof Element?Element.prototype:{},s=l.matches||l.matchesSelector||l.webkitMatchesSelector||l.mozMatchesSelector||l.msMatchesSelector||l.oMatchesSelector,a=function(e,t){if(!e||1!==e.nodeType)return!1;if(s)return s.call(e,t);for(var r=e.parentNode.querySelectorAll(t),n=0;n<r.length;n++)if(r[n]==e)return!0;return!1};function d(e,t,r){for(var n=r?e:e.parentNode;n&&n.nodeType!==document.DOCUMENT_NODE&&n.nodeType!==document.DOCUMENT_FRAGMENT_NODE;){if(a(n,t))return n;n=n.parentNode}return a(n,t)?n:null}var u=window.addEventListener?"addEventListener":"attachEvent",c=window.removeEventListener?"removeEventListener":"detachEvent",f="addEventListener"!=u?"on":"",h={bind:function(e,t,r,n){return e[u](f+t,r,n||!1),r},unbind:function(e,t,r,n){return e[c](f+t,r,n||!1),r}},p=["focus","blur"];function v(e,t){if("string"!=typeof e)throw new TypeError("String expected");t=t||document;var r=/<([\w:]+)/.exec(e);if(!r)return t.createTextNode(e);e=e.replace(/^\s+|\s+$/g,"");var n=r[1];if("body"==n){return(i=t.createElement("html")).innerHTML=e,i.removeChild(i.lastChild)}var i,o=b[n]||b._default,l=o[0],s=o[1],a=o[2];for((i=t.createElement("div")).innerHTML=s+e+a;l--;)i=i.lastChild;if(i.firstChild==i.lastChild)return i.removeChild(i.firstChild);for(var d=t.createDocumentFragment();i.firstChild;)d.appendChild(i.removeChild(i.firstChild));return d}var m,y={bind:function(r,n,e,i,t){return-1!==p.indexOf(e)&&(t=!0),h.bind(r,e,function(e){var t=e.target||e.srcElement;e.delegateTarget=d(t,n,!0),e.delegateTarget&&i.call(r,e)},t)},unbind:function(e,t,r,n){return-1!==p.indexOf(t)&&(n=!0),h.unbind(e,t,r,n)}},g=!1;"undefined"!=typeof document&&((m=document.createElement("div")).innerHTML=' <link/><table></table><a href="/a">a</a><input type="checkbox"/>',g=!m.getElementsByTagName("link").length,m=void 0);var b={legend:[1,"<fieldset>","</fieldset>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],_default:g?[1,"X<div>","</div>"]:[0,"",""]};b.td=b.th=[3,"<table><tbody><tr>","</tr></tbody></table>"],b.option=b.optgroup=[1,'<select multiple="multiple">',"</select>"],b.thead=b.tbody=b.colgroup=b.caption=b.tfoot=[1,"<table>","</table>"],b.polyline=b.ellipse=b.polygon=b.circle=b.text=b.line=b.path=b.rect=b.g=[1,'<svg xmlns="http://www.w3.org/2000/svg" version="1.1">',"</svg>"],e.attr=function(e,t,r){return 2==arguments.length?e.getAttribute(t):null===r?e.removeAttribute(t):(e.setAttribute(t,r),e)},e.classes=function(e){return new r(e)},e.clear=function(e){for(var t;e.childNodes.length;)t=e.childNodes[0],e.removeChild(t);return e},e.closest=d,e.delegate=y,e.domify=v,e.event=h,e.matches=a,e.query=function(e,t){return(t=t||document).querySelector(e)},e.queryAll=function(e,t){return(t=t||document).querySelectorAll(e)},e.remove=function(e){e.parentNode&&e.parentNode.removeChild(e)},Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.MinDom={})}(this,function(e){"use strict";var s=Object.prototype.toString,u=Object.prototype.hasOwnProperty;function o(e,t){var r;if(void 0!==e){var n,i,o,l=(n=e,"[object Array]"===s.call(n)?d:c);for(var a in e)if(i=e,o=a,u.call(i,o)&&!1===t(r=e[a],l(a)))return r}}function c(e){return e}function d(e){return Number(e)}function n(e,t){if(i)return e.indexOf(t);for(var r=0;r<e.length;++r)if(e[r]===t)return r;return-1}var i=[].indexOf,t=/\s+/,l=Object.prototype.toString;function r(e){if(!e||!e.nodeType)throw new Error("A DOM element reference is required");this.el=e,this.list=e.classList}r.prototype.add=function(e){if(this.list)return this.list.add(e),this;var t=this.array();return~n(t,e)||t.push(e),this.el.className=t.join(" "),this},r.prototype.remove=function(e){if("[object RegExp]"==l.call(e))return this.removeMatching(e);if(this.list)return this.list.remove(e),this;var t=this.array(),r=n(t,e);return~r&&t.splice(r,1),this.el.className=t.join(" "),this},r.prototype.removeMatching=function(e){for(var t=this.array(),r=0;r<t.length;r++)e.test(t[r])&&this.remove(t[r]);return this},r.prototype.toggle=function(e,t){return this.list?void 0!==t&&t===this.list.toggle(e,t)||this.list.toggle(e):void 0!==t?t?this.add(e):this.remove(e):this.has(e)?this.remove(e):this.add(e),this},r.prototype.array=function(){var e=(this.el.getAttribute("class")||"").replace(/^\s+|\s+$/g,"").split(t);return""===e[0]&&e.shift(),e},r.prototype.has=r.prototype.contains=function(e){return this.list?this.list.contains(e):!!~n(this.array(),e)};var a="undefined"!=typeof Element?Element.prototype:{},f=a.matches||a.matchesSelector||a.webkitMatchesSelector||a.mozMatchesSelector||a.msMatchesSelector||a.oMatchesSelector,h=function(e,t){if(!e||1!==e.nodeType)return!1;if(f)return f.call(e,t);for(var r=e.parentNode.querySelectorAll(t),n=0;n<r.length;n++)if(r[n]==e)return!0;return!1};function p(e,t,r){for(var n=r?e:e.parentNode;n&&n.nodeType!==document.DOCUMENT_NODE&&n.nodeType!==document.DOCUMENT_FRAGMENT_NODE;){if(h(n,t))return n;n=n.parentNode}return h(n,t)?n:null}var v=window.addEventListener?"addEventListener":"attachEvent",y=window.removeEventListener?"removeEventListener":"detachEvent",m="addEventListener"!=v?"on":"",g={bind:function(e,t,r,n){return e[v](m+t,r,n||!1),r},unbind:function(e,t,r,n){return e[y](m+t,r,n||!1),r}},b=["focus","blur"];function E(e,t){if("string"!=typeof e)throw new TypeError("String expected");t=t||document;var r=/<([\w:]+)/.exec(e);if(!r)return t.createTextNode(e);e=e.replace(/^\s+|\s+$/g,"");var n=r[1];if("body"==n){return(i=t.createElement("html")).innerHTML=e,i.removeChild(i.lastChild)}var i,o=M[n]||M._default,l=o[0],a=o[1],s=o[2];for((i=t.createElement("div")).innerHTML=a+e+s;l--;)i=i.lastChild;if(i.firstChild==i.lastChild)return i.removeChild(i.firstChild);for(var u=t.createDocumentFragment();i.firstChild;)u.appendChild(i.removeChild(i.firstChild));return u}var N,w={bind:function(r,n,e,i,t){return-1!==b.indexOf(e)&&(t=!0),g.bind(r,e,function(e){var t=e.target||e.srcElement;e.delegateTarget=p(t,n,!0),e.delegateTarget&&i.call(r,e)},t)},unbind:function(e,t,r,n){return-1!==b.indexOf(t)&&(n=!0),g.unbind(e,t,r,n)}},C=!1;"undefined"!=typeof document&&((N=document.createElement("div")).innerHTML=' <link/><table></table><a href="/a">a</a><input type="checkbox"/>',C=!N.getElementsByTagName("link").length,N=void 0);var M={legend:[1,"<fieldset>","</fieldset>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],_default:C?[1,"X<div>","</div>"]:[0,"",""]};M.td=M.th=[3,"<table><tbody><tr>","</tr></tbody></table>"],M.option=M.optgroup=[1,'<select multiple="multiple">',"</select>"],M.thead=M.tbody=M.colgroup=M.caption=M.tfoot=[1,"<table>","</table>"],M.polyline=M.ellipse=M.polygon=M.circle=M.text=M.line=M.path=M.rect=M.g=[1,'<svg xmlns="http://www.w3.org/2000/svg" version="1.1">',"</svg>"],e.assignStyle=function(e){for(var r=e.style,t=arguments.length,n=Array(1<t?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return o(n,function(e){e&&o(e,function(e,t){r[t]=e})}),e},e.attr=function(e,t,r){return 2==arguments.length?e.getAttribute(t):null===r?e.removeAttribute(t):(e.setAttribute(t,r),e)},e.classes=function(e){return new r(e)},e.clear=function(e){for(var t;e.childNodes.length;)t=e.childNodes[0],e.removeChild(t);return e},e.closest=p,e.delegate=w,e.domify=E,e.event=g,e.matches=h,e.query=function(e,t){return(t=t||document).querySelector(e)},e.queryAll=function(e,t){return(t=t||document).querySelectorAll(e)},e.remove=function(e){e.parentNode&&e.parentNode.removeChild(e)},Object.defineProperty(e,"__esModule",{value:!0})}); |
{ | ||
"name": "min-dom", | ||
"version": "3.1.3", | ||
"version": "3.2.0", | ||
"description": "A minimal dom utility toolbelt", | ||
@@ -39,3 +39,4 @@ "main": "dist/index.js", | ||
"indexof": "0.0.1", | ||
"matches-selector": "^1.2.0" | ||
"matches-selector": "^1.2.0", | ||
"min-dash": "^3.8.1" | ||
}, | ||
@@ -42,0 +43,0 @@ "devDependencies": { |
# min-dom | ||
[![Build Status](https://travis-ci.org/bpmn-io/min-dom.svg?branch=master)](https://travis-ci.org/bpmn-io/min-dom) | ||
[![CI](https://github.com/bpmn-io/min-dom/workflows/CI/badge.svg)](https://github.com/bpmn-io/min-dom/actions?query=workflow%3ACI) | ||
@@ -13,9 +13,6 @@ A minimal dom utility toolbelt. Library friendly and based on utilities provided by [component](https://github.com/component). | ||
```bash | ||
$ browserify index.js \ | ||
--standalone=dom \ | ||
--plugin=tinyify | \ | ||
gzip > min-dom.min.js.gz | ||
$ du -b *.gz | ||
1842 min-dom.min.js.gz | ||
$ npm run distro | ||
$ gzip dist/min-dom.min.js | ||
$ du -b dist/*.gz | ||
2003 min-dom.min.js.gz | ||
``` | ||
@@ -28,2 +25,3 @@ | ||
* `assignStyle` - add inline styles to a node | ||
* `attr` - get and set node attributes | ||
@@ -41,3 +39,3 @@ * `classes` - class name helper | ||
## Related | ||
## Related | ||
@@ -44,0 +42,0 @@ * [min-dash](https://github.com/bpmn-io/min-dash) - minimal lodash inspired utility toolbelt |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
55081
10
1633
5
46
+ Addedmin-dash@^3.8.1
+ Addedmin-dash@3.8.1(transitive)