Comparing version 4.1.0 to 5.0.0
@@ -1,5 +0,4 @@ | ||
'use strict'; | ||
import { forEach } from 'min-dash'; | ||
export { default as domify } from 'domify'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
function _mergeNamespaces(n, m) { | ||
@@ -21,77 +20,2 @@ m.forEach(function (e) { | ||
/** | ||
* Flatten array, one level deep. | ||
* | ||
* @param {Array<?>} arr | ||
* | ||
* @return {Array<?>} | ||
*/ | ||
const nativeToString = Object.prototype.toString; | ||
const 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) { | ||
let val, | ||
result; | ||
if (isUndefined(collection)) { | ||
return; | ||
} | ||
const convertKey = isArray(collection) ? toNum : identity; | ||
for (let 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. | ||
@@ -377,4 +301,4 @@ * | ||
bind: bind_1, | ||
unbind: unbind_1, | ||
'default': componentEvent | ||
default: componentEvent, | ||
unbind: unbind_1 | ||
}, [componentEvent]); | ||
@@ -386,2 +310,3 @@ | ||
/** | ||
@@ -441,116 +366,2 @@ * Delegate event `type` to `selector` | ||
/** | ||
* Expose `parse`. | ||
*/ | ||
var domify = parse; | ||
/** | ||
* Tests for browser support. | ||
*/ | ||
var innerHTMLBug = false; | ||
var bugTestDiv; | ||
if (typeof document !== 'undefined') { | ||
bugTestDiv = document.createElement('div'); | ||
// Setup | ||
bugTestDiv.innerHTML = ' <link/><table></table><a href="/a">a</a><input type="checkbox"/>'; | ||
// Make sure that link elements get serialized correctly by innerHTML | ||
// This requires a wrapper element in IE | ||
innerHTMLBug = !bugTestDiv.getElementsByTagName('link').length; | ||
bugTestDiv = undefined; | ||
} | ||
/** | ||
* Wrap map from jquery. | ||
*/ | ||
var map = { | ||
legend: [1, '<fieldset>', '</fieldset>'], | ||
tr: [2, '<table><tbody>', '</tbody></table>'], | ||
col: [2, '<table><tbody></tbody><colgroup>', '</colgroup></table>'], | ||
// for script/link/style tags to work in IE6-8, you have to wrap | ||
// in a div with a non-whitespace character in front, ha! | ||
_default: innerHTMLBug ? [1, 'X<div>', '</div>'] : [0, '', ''] | ||
}; | ||
map.td = | ||
map.th = [3, '<table><tbody><tr>', '</tr></tbody></table>']; | ||
map.option = | ||
map.optgroup = [1, '<select multiple="multiple">', '</select>']; | ||
map.thead = | ||
map.tbody = | ||
map.colgroup = | ||
map.caption = | ||
map.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>']; | ||
/** | ||
* Parse `html` and return a DOM Node instance, which could be a TextNode, | ||
* HTML DOM Node of some kind (<div> for example), or a DocumentFragment | ||
* instance, depending on the contents of the `html` string. | ||
* | ||
* @param {String} html - HTML string to "domify" | ||
* @param {Document} doc - The `document` instance to create the Node for | ||
* @return {DOMNode} the TextNode, DOM Node, or DocumentFragment instance | ||
* @api private | ||
*/ | ||
function parse(html, doc) { | ||
if ('string' != typeof html) throw new TypeError('String expected'); | ||
// default to the global `document` object | ||
if (!doc) doc = document; | ||
// tag name | ||
var m = /<([\w:]+)/.exec(html); | ||
if (!m) return doc.createTextNode(html); | ||
html = html.replace(/^\s+|\s+$/g, ''); // Remove leading/trailing whitespace | ||
var tag = m[1]; | ||
// body support | ||
if (tag == 'body') { | ||
var el = doc.createElement('html'); | ||
el.innerHTML = html; | ||
return el.removeChild(el.lastChild); | ||
} | ||
// wrap map | ||
var wrap = Object.prototype.hasOwnProperty.call(map, tag) ? map[tag] : map._default; | ||
var depth = wrap[0]; | ||
var prefix = wrap[1]; | ||
var suffix = wrap[2]; | ||
var el = doc.createElement('div'); | ||
el.innerHTML = prefix + html + suffix; | ||
while (depth--) el = el.lastChild; | ||
// one element | ||
if (el.firstChild == el.lastChild) { | ||
return el.removeChild(el.firstChild); | ||
} | ||
// several elements | ||
var fragment = doc.createDocumentFragment(); | ||
while (el.firstChild) { | ||
fragment.appendChild(el.removeChild(el.firstChild)); | ||
} | ||
return fragment; | ||
} | ||
var domify$1 = domify; | ||
function query(selector, el) { | ||
@@ -572,14 +383,3 @@ el = el || document; | ||
exports.assignStyle = assign; | ||
exports.attr = attr; | ||
exports.classes = classes; | ||
exports.clear = clear; | ||
exports.closest = closest; | ||
exports.delegate = delegate; | ||
exports.domify = domify$1; | ||
exports.event = event; | ||
exports.matches = matches; | ||
exports.query = query; | ||
exports.queryAll = all; | ||
exports.remove = remove; | ||
export { assign as assignStyle, attr, classes, clear, closest, delegate, event, matches, query, all as queryAll, remove }; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "min-dom", | ||
"version": "4.1.0", | ||
"version": "5.0.0", | ||
"description": "A minimal dom utility toolbelt", | ||
"main": "dist/index.js", | ||
"module": "dist/index.esm.js", | ||
"types": "dist/index.d.ts", | ||
"type": "module", | ||
"exports": { | ||
".": { | ||
"import": "./dist/index.js", | ||
"types": "./dist/index.d.ts" | ||
}, | ||
"./package.json": "./package.json" | ||
}, | ||
"types": "./dist/index.d.ts", | ||
"scripts": { | ||
"all": "run-s lint test test:types distro", | ||
"bundle": "rollup -c", | ||
"distro": "run-s bundle test:integration", | ||
"lint": "eslint .", | ||
"prepare": "run-s distro", | ||
"test": "karma start", | ||
"test:types": "tsc --project test/integration --pretty --noEmit", | ||
"test:integration": "karma start test/integration/karma.conf.js" | ||
"all": "run-s lint test check-types", | ||
"pretest": "run-s bundle", | ||
"bundle": "rollup -c --bundleConfigAsCjs", | ||
"lint": "eslint . --ext js,cjs", | ||
"prepare": "run-s bundle", | ||
"test": "karma start karma.conf.cjs", | ||
"check-types": "tsc --noEmit" | ||
}, | ||
@@ -36,28 +41,26 @@ "keywords": [ | ||
"dependencies": { | ||
"component-event": "^0.2.1", | ||
"domify": "^1.4.1", | ||
"min-dash": "^4.0.0" | ||
"domify": "^2.0.0", | ||
"min-dash": "^4.2.1" | ||
}, | ||
"devDependencies": { | ||
"@rollup/plugin-babel": "^5.3.1", | ||
"@rollup/plugin-commonjs": "^22.0.2", | ||
"@rollup/plugin-node-resolve": "^14.1.0", | ||
"@types/chai": "^4.3.3", | ||
"@types/mocha": "^9.1.1", | ||
"chai": "^4.3.6", | ||
"eslint": "^8.23.1", | ||
"eslint-plugin-bpmn-io": "^0.15.1", | ||
"karma": "^6.4.0", | ||
"@rollup/plugin-commonjs": "^25.0.7", | ||
"@rollup/plugin-node-resolve": "^15.2.3", | ||
"@types/chai": "^4.3.12", | ||
"@types/mocha": "^10.0.6", | ||
"chai": "^4.4.1", | ||
"component-event": "^0.2.1", | ||
"eslint": "^8.57.0", | ||
"eslint-plugin-bpmn-io": "^1.0.0", | ||
"karma": "^6.4.3", | ||
"karma-chai": "^0.1.0", | ||
"karma-chrome-launcher": "^3.1.1", | ||
"karma-firefox-launcher": "^2.1.2", | ||
"karma-chrome-launcher": "^3.2.0", | ||
"karma-firefox-launcher": "^2.1.3", | ||
"karma-mocha": "^2.0.1", | ||
"karma-webpack": "^5.0.0", | ||
"mocha": "^10.0.0", | ||
"mocha": "^10.3.0", | ||
"npm-run-all": "^4.1.2", | ||
"puppeteer": "^17.1.3", | ||
"rollup": "^2.79.0", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"typescript": "^4.8.3", | ||
"webpack": "^5.74.0" | ||
"puppeteer": "^22.4.0", | ||
"rollup": "^4.12.1", | ||
"typescript": "^5.3.3", | ||
"webpack": "^5.90.3" | ||
}, | ||
@@ -64,0 +67,0 @@ "files": [ |
@@ -10,9 +10,9 @@ # min-dom | ||
This library is tiny (`< 2Kb` in size) and still exposes all fundamental utilities: | ||
This library is tiny (`2Kb` in size) and still exposes all fundamental utilities: | ||
```bash | ||
$ npm run distro | ||
$ gzip dist/min-dom.min.js | ||
$ npm run bundle | ||
$ gzip dist/index.js | ||
$ du -b dist/*.gz | ||
1675 min-dom.min.js.gz | ||
2351 index.js.gz | ||
``` | ||
@@ -19,0 +19,0 @@ |
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
2
20
Yes
30854
7
373
1
+ Addeddomify@2.0.0(transitive)
- Removedcomponent-event@^0.2.1
- Removedcomponent-event@0.2.1(transitive)
- Removeddomify@1.4.2(transitive)
Updateddomify@^2.0.0
Updatedmin-dash@^4.2.1