Comparing version 1.0.2 to 1.0.3
@@ -128,2 +128,6 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.morphdom = f()}})(function(){var define,module,exports;module={exports:(exports={})}; | ||
function defaultGetNodeKey(node) { | ||
return node.id; | ||
} | ||
function morphdom(fromNode, toNode, options) { | ||
@@ -140,2 +144,3 @@ if (!options) { | ||
var unmatchedEls = {}; | ||
var getNodeKey = options.getNodeKey || defaultGetNodeKey; | ||
var onNodeDiscarded = options.onNodeDiscarded || noop; | ||
@@ -148,3 +153,3 @@ var onBeforeMorphEl = options.onBeforeMorphEl || noop; | ||
function removeNodeHelper(node, nestedInSavedEl) { | ||
var id = node.id; | ||
var id = getNodeKey(node); | ||
// If the node has an ID then save it off since we will want | ||
@@ -176,3 +181,3 @@ // to reuse it in case the target DOM tree has a DOM element | ||
if (!curChild.id) { | ||
if (!getNodeKey(curChild)) { | ||
// We only want to handle nodes that don't have an ID to avoid double | ||
@@ -199,3 +204,3 @@ // walking the same saved element. | ||
if (alreadyVisited) { | ||
if (!node.id) { | ||
if (!getNodeKey(node)) { | ||
onNodeDiscarded(node); | ||
@@ -210,6 +215,6 @@ walkDiscardedChildNodes(node); | ||
function morphEl(fromEl, toEl, alreadyVisited, childrenOnly) { | ||
if (toEl.id) { | ||
if (getNodeKey(toEl)) { | ||
// If an element with an ID is being morphed then it is will be in the final | ||
// DOM so clear it out of the saved elements collection | ||
delete savedEls[toEl.id]; | ||
delete savedEls[getNodeKey(toEl)]; | ||
} | ||
@@ -241,6 +246,6 @@ | ||
toNextSibling = curToNodeChild.nextSibling; | ||
curToNodeId = curToNodeChild.id; | ||
curToNodeId = getNodeKey(curToNodeChild); | ||
while(curFromNodeChild) { | ||
var curFromNodeId = curFromNodeChild.id; | ||
var curFromNodeId = getNodeKey(curFromNodeChild); | ||
fromNextSibling = curFromNodeChild.nextSibling; | ||
@@ -399,2 +404,3 @@ | ||
module.exports = morphdom; | ||
return module.exports;}); |
@@ -127,2 +127,6 @@ // Create a range object for efficently rendering strings to elements. | ||
function defaultGetNodeKey(node) { | ||
return node.id; | ||
} | ||
function morphdom(fromNode, toNode, options) { | ||
@@ -139,2 +143,3 @@ if (!options) { | ||
var unmatchedEls = {}; | ||
var getNodeKey = options.getNodeKey || defaultGetNodeKey; | ||
var onNodeDiscarded = options.onNodeDiscarded || noop; | ||
@@ -147,3 +152,3 @@ var onBeforeMorphEl = options.onBeforeMorphEl || noop; | ||
function removeNodeHelper(node, nestedInSavedEl) { | ||
var id = node.id; | ||
var id = getNodeKey(node); | ||
// If the node has an ID then save it off since we will want | ||
@@ -175,3 +180,3 @@ // to reuse it in case the target DOM tree has a DOM element | ||
if (!curChild.id) { | ||
if (!getNodeKey(curChild)) { | ||
// We only want to handle nodes that don't have an ID to avoid double | ||
@@ -198,3 +203,3 @@ // walking the same saved element. | ||
if (alreadyVisited) { | ||
if (!node.id) { | ||
if (!getNodeKey(node)) { | ||
onNodeDiscarded(node); | ||
@@ -209,6 +214,6 @@ walkDiscardedChildNodes(node); | ||
function morphEl(fromEl, toEl, alreadyVisited, childrenOnly) { | ||
if (toEl.id) { | ||
if (getNodeKey(toEl)) { | ||
// If an element with an ID is being morphed then it is will be in the final | ||
// DOM so clear it out of the saved elements collection | ||
delete savedEls[toEl.id]; | ||
delete savedEls[getNodeKey(toEl)]; | ||
} | ||
@@ -240,6 +245,6 @@ | ||
toNextSibling = curToNodeChild.nextSibling; | ||
curToNodeId = curToNodeChild.id; | ||
curToNodeId = getNodeKey(curToNodeChild); | ||
while(curFromNodeChild) { | ||
var curFromNodeId = curFromNodeChild.id; | ||
var curFromNodeId = getNodeKey(curFromNodeChild); | ||
fromNextSibling = curFromNodeChild.nextSibling; | ||
@@ -397,2 +402,2 @@ | ||
module.exports = morphdom; | ||
module.exports = morphdom; |
@@ -38,3 +38,3 @@ { | ||
"dependencies": {}, | ||
"version": "1.0.2" | ||
"version": "1.0.3" | ||
} |
Sorry, the diff of this file is not supported yet
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
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 2 instances in 1 package
15642653
696
681
0