@riotjs/dom-bindings
Advanced tools
Comparing version 5.0.0-alpha.0 to 5.0.0-alpha.1
@@ -194,20 +194,11 @@ (function (global, factory) { | ||
// fork of https://github.com/WebReflection/udomdiff | ||
// fork of https://github.com/WebReflection/udomdiff version 1.1.0 | ||
// due to https://github.com/WebReflection/udomdiff/pull/2 | ||
/* eslint-disable */ | ||
/** | ||
* Remove a node from the DOM | ||
* @param {HTMLElement} node - target node to remove | ||
* @returns {undefined} void function | ||
*/ | ||
const drop = node => { | ||
const {parentNode} = node; | ||
// DOM manipulation helper functions | ||
const drop = node => node && node.parentNode && node.parentNode.removeChild(node); | ||
const append = (node, prev) => prev && prev.parentNode && prev.parentNode.insertBefore(node, prev); | ||
const replace = (node, prev) => prev && prev.parentNode && prev.parentNode.replaceChild(node, prev); | ||
if (parentNode) { | ||
if (node.remove) node.remove(); | ||
else parentNode.removeChild(node); | ||
} | ||
}; | ||
/** | ||
@@ -242,3 +233,3 @@ * @param {Node} parentNode The container where children live | ||
while (bStart < bEnd) | ||
parentNode.insertBefore(get(b[bStart++], 1), node); | ||
append(get(b[bStart++], 1), node); | ||
} | ||
@@ -278,7 +269,7 @@ // remove head or tail: fast path | ||
const node = get(a[--aEnd], -1).nextSibling; | ||
parentNode.insertBefore( | ||
append( | ||
get(b[bStart++], 1), | ||
get(a[aStart++], -1).nextSibling | ||
); | ||
parentNode.insertBefore(get(b[--bEnd], 1), node); | ||
append(get(b[--bEnd], 1), node); | ||
// mark the future index as identical (yeah, it's dirty, but cheap 👍) | ||
@@ -329,3 +320,3 @@ // The main reason to do this, is that when a[aEnd] will be reached, | ||
while (bStart < index) | ||
parentNode.insertBefore(get(b[bStart++], 1), node); | ||
append(get(b[bStart++], 1), node); | ||
} | ||
@@ -336,3 +327,3 @@ // if the effort wasn't good enough, fallback to a replace, | ||
else { | ||
parentNode.replaceChild( | ||
replace( | ||
get(b[bStart++], 1), | ||
@@ -339,0 +330,0 @@ get(a[aStart++], -1) |
{ | ||
"name": "@riotjs/dom-bindings", | ||
"version": "5.0.0-alpha.0", | ||
"version": "5.0.0-alpha.1", | ||
"description": "Riot.js DOM bindings", | ||
@@ -35,2 +35,6 @@ "main": "dist/umd.dom-bindings.js", | ||
], | ||
"nyc": { | ||
"include": "src", | ||
"exclude": "src/util/udomdiff.js" | ||
}, | ||
"author": "Gianluca Guarini <gianluca.guarini@gmail.com> (http://gianlucaguarini.com)", | ||
@@ -37,0 +41,0 @@ "license": "MIT", |
@@ -19,20 +19,11 @@ /** | ||
// fork of https://github.com/WebReflection/udomdiff | ||
// fork of https://github.com/WebReflection/udomdiff version 1.1.0 | ||
// due to https://github.com/WebReflection/udomdiff/pull/2 | ||
/* eslint-disable */ | ||
/** | ||
* Remove a node from the DOM | ||
* @param {HTMLElement} node - target node to remove | ||
* @returns {undefined} void function | ||
*/ | ||
const drop = node => { | ||
const {parentNode} = node | ||
// DOM manipulation helper functions | ||
const drop = node => node && node.parentNode && node.parentNode.removeChild(node) | ||
const append = (node, prev) => prev && prev.parentNode && prev.parentNode.insertBefore(node, prev) | ||
const replace = (node, prev) => prev && prev.parentNode && prev.parentNode.replaceChild(node, prev) | ||
if (parentNode) { | ||
if (node.remove) node.remove() | ||
else parentNode.removeChild(node) | ||
} | ||
} | ||
/** | ||
@@ -67,3 +58,3 @@ * @param {Node} parentNode The container where children live | ||
while (bStart < bEnd) | ||
parentNode.insertBefore(get(b[bStart++], 1), node) | ||
append(get(b[bStart++], 1), node) | ||
} | ||
@@ -103,7 +94,7 @@ // remove head or tail: fast path | ||
const node = get(a[--aEnd], -1).nextSibling | ||
parentNode.insertBefore( | ||
append( | ||
get(b[bStart++], 1), | ||
get(a[aStart++], -1).nextSibling | ||
) | ||
parentNode.insertBefore(get(b[--bEnd], 1), node) | ||
append(get(b[--bEnd], 1), node) | ||
// mark the future index as identical (yeah, it's dirty, but cheap 👍) | ||
@@ -154,3 +145,3 @@ // The main reason to do this, is that when a[aEnd] will be reached, | ||
while (bStart < index) | ||
parentNode.insertBefore(get(b[bStart++], 1), node) | ||
append(get(b[bStart++], 1), node) | ||
} | ||
@@ -161,3 +152,3 @@ // if the effort wasn't good enough, fallback to a replace, | ||
else { | ||
parentNode.replaceChild( | ||
replace( | ||
get(b[bStart++], 1), | ||
@@ -164,0 +155,0 @@ get(a[aStart++], -1) |
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
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
107043
2549