Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions dist/morphdom-esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ function morphdomFactory(morphAttrs) {
var skipFromChildren = options.skipFromChildren || noop;
var addChild = options.addChild || function(parent, child){ return parent.appendChild(child); };
var childrenOnly = options.childrenOnly === true;
var canUseMoveBefore = typeof Element.prototype.moveBefore === 'function';

// This object is used as a lookup to quickly find all keyed elements in the original DOM tree.
var fromNodesLookup = Object.create(null);
Expand Down Expand Up @@ -582,10 +583,25 @@ function morphdomFactory(morphAttrs) {
// Let's move the original DOM node into the current position and morph
// it.

// NOTE: We use insertBefore instead of replaceChild because we want to go through
// the `removeNode()` function for the node that is being discarded so that
// all lifecycle hooks are correctly invoked
fromEl.insertBefore(matchingFromEl, curFromNodeChild);
if (canUseMoveBefore) {
try {
// We first try and use the new `moveBefore()` API if it's available
// `moveBefore()` doesn't remove and reinsert a node, instead the state
// of the node is preserved. This allows for things like iframes, animations,
// popeovers, etc to continue to be in the state they were in before the move
fromEl.moveBefore(matchingFromEl, curFromNodeChild);
} catch (err) {
// If `moveBefore()` errors for some reason, fall back to
// `insertBefore()`
fromEl.insertBefore(matchingFromEl, curFromNodeChild);
}
} else {
// NOTE: We use insertBefore instead of replaceChild because we want to go through
// the `removeNode()` function for the node that is being discarded so that
// all lifecycle hooks are correctly invoked
fromEl.insertBefore(matchingFromEl, curFromNodeChild);
}


// fromNextSibling = curFromNodeChild.nextSibling;

Expand Down
24 changes: 20 additions & 4 deletions dist/morphdom-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ function morphdomFactory(morphAttrs) {
var skipFromChildren = options.skipFromChildren || noop;
var addChild = options.addChild || function(parent, child){ return parent.appendChild(child); };
var childrenOnly = options.childrenOnly === true;
var canUseMoveBefore = typeof Element.prototype.moveBefore === 'function';

// This object is used as a lookup to quickly find all keyed elements in the original DOM tree.
var fromNodesLookup = Object.create(null);
Expand Down Expand Up @@ -520,10 +521,25 @@ function morphdomFactory(morphAttrs) {
// Let's move the original DOM node into the current position and morph
// it.

// NOTE: We use insertBefore instead of replaceChild because we want to go through
// the `removeNode()` function for the node that is being discarded so that
// all lifecycle hooks are correctly invoked
fromEl.insertBefore(matchingFromEl, curFromNodeChild);
if (canUseMoveBefore) {
try {
// We first try and use the new `moveBefore()` API if it's available
// `moveBefore()` doesn't remove and reinsert a node, instead the state
// of the node is preserved. This allows for things like iframes, animations,
// popeovers, etc to continue to be in the state they were in before the move
fromEl.moveBefore(matchingFromEl, curFromNodeChild);
} catch (err) {
// If `moveBefore()` errors for some reason, fall back to
// `insertBefore()`
fromEl.insertBefore(matchingFromEl, curFromNodeChild);
}
} else {
// NOTE: We use insertBefore instead of replaceChild because we want to go through
// the `removeNode()` function for the node that is being discarded so that
// all lifecycle hooks are correctly invoked
fromEl.insertBefore(matchingFromEl, curFromNodeChild);
}


// fromNextSibling = curFromNodeChild.nextSibling;

Expand Down
24 changes: 20 additions & 4 deletions dist/morphdom-umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@
var skipFromChildren = options.skipFromChildren || noop;
var addChild = options.addChild || function(parent, child){ return parent.appendChild(child); };
var childrenOnly = options.childrenOnly === true;
var canUseMoveBefore = typeof Element.prototype.moveBefore === 'function';

// This object is used as a lookup to quickly find all keyed elements in the original DOM tree.
var fromNodesLookup = Object.create(null);
Expand Down Expand Up @@ -588,10 +589,25 @@
// Let's move the original DOM node into the current position and morph
// it.

// NOTE: We use insertBefore instead of replaceChild because we want to go through
// the `removeNode()` function for the node that is being discarded so that
// all lifecycle hooks are correctly invoked
fromEl.insertBefore(matchingFromEl, curFromNodeChild);
if (canUseMoveBefore) {
try {
// We first try and use the new `moveBefore()` API if it's available
// `moveBefore()` doesn't remove and reinsert a node, instead the state
// of the node is preserved. This allows for things like iframes, animations,
// popeovers, etc to continue to be in the state they were in before the move
fromEl.moveBefore(matchingFromEl, curFromNodeChild);
} catch (err) {
// If `moveBefore()` errors for some reason, fall back to
// `insertBefore()`
fromEl.insertBefore(matchingFromEl, curFromNodeChild);
}
} else {
// NOTE: We use insertBefore instead of replaceChild because we want to go through
// the `removeNode()` function for the node that is being discarded so that
// all lifecycle hooks are correctly invoked
fromEl.insertBefore(matchingFromEl, curFromNodeChild);
}


// fromNextSibling = curFromNodeChild.nextSibling;

Expand Down
2 changes: 1 addition & 1 deletion dist/morphdom-umd.min.js

Large diffs are not rendered by default.

24 changes: 20 additions & 4 deletions dist/morphdom.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ function morphdomFactory(morphAttrs) {
var skipFromChildren = options.skipFromChildren || noop;
var addChild = options.addChild || function(parent, child){ return parent.appendChild(child); };
var childrenOnly = options.childrenOnly === true;
var canUseMoveBefore = typeof Element.prototype.moveBefore === 'function';

// This object is used as a lookup to quickly find all keyed elements in the original DOM tree.
var fromNodesLookup = Object.create(null);
Expand Down Expand Up @@ -584,10 +585,25 @@ function morphdomFactory(morphAttrs) {
// Let's move the original DOM node into the current position and morph
// it.

// NOTE: We use insertBefore instead of replaceChild because we want to go through
// the `removeNode()` function for the node that is being discarded so that
// all lifecycle hooks are correctly invoked
fromEl.insertBefore(matchingFromEl, curFromNodeChild);
if (canUseMoveBefore) {
try {
// We first try and use the new `moveBefore()` API if it's available
// `moveBefore()` doesn't remove and reinsert a node, instead the state
// of the node is preserved. This allows for things like iframes, animations,
// popeovers, etc to continue to be in the state they were in before the move
fromEl.moveBefore(matchingFromEl, curFromNodeChild);
} catch (err) {
// If `moveBefore()` errors for some reason, fall back to
// `insertBefore()`
fromEl.insertBefore(matchingFromEl, curFromNodeChild);
}
} else {
// NOTE: We use insertBefore instead of replaceChild because we want to go through
// the `removeNode()` function for the node that is being discarded so that
// all lifecycle hooks are correctly invoked
fromEl.insertBefore(matchingFromEl, curFromNodeChild);
}


// fromNextSibling = curFromNodeChild.nextSibling;

Expand Down
24 changes: 20 additions & 4 deletions src/morphdom.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export default function morphdomFactory(morphAttrs) {
var skipFromChildren = options.skipFromChildren || noop;
var addChild = options.addChild || function(parent, child){ return parent.appendChild(child); };
var childrenOnly = options.childrenOnly === true;
var canUseMoveBefore = typeof Element.prototype.moveBefore === 'function';

// This object is used as a lookup to quickly find all keyed elements in the original DOM tree.
var fromNodesLookup = Object.create(null);
Expand Down Expand Up @@ -293,10 +294,25 @@ export default function morphdomFactory(morphAttrs) {
// Let's move the original DOM node into the current position and morph
// it.

// NOTE: We use insertBefore instead of replaceChild because we want to go through
// the `removeNode()` function for the node that is being discarded so that
// all lifecycle hooks are correctly invoked
fromEl.insertBefore(matchingFromEl, curFromNodeChild);
if (canUseMoveBefore) {
try {
// We first try and use the new `moveBefore()` API if it's available
// `moveBefore()` doesn't remove and reinsert a node, instead the state
// of the node is preserved. This allows for things like iframes, animations,
// popeovers, etc to continue to be in the state they were in before the move
fromEl.moveBefore(matchingFromEl, curFromNodeChild);
} catch (err) {
// If `moveBefore()` errors for some reason, fall back to
// `insertBefore()`
fromEl.insertBefore(matchingFromEl, curFromNodeChild);
}
} else {
// NOTE: We use insertBefore instead of replaceChild because we want to go through
// the `removeNode()` function for the node that is being discarded so that
// all lifecycle hooks are correctly invoked
fromEl.insertBefore(matchingFromEl, curFromNodeChild);
}


// fromNextSibling = curFromNodeChild.nextSibling;

Expand Down