Skip to content

Commit

Permalink
updated: improved loop performance
Browse files Browse the repository at this point in the history
  • Loading branch information
GianlucaGuarini committed Jun 2, 2019
1 parent e389ec2 commit 3741c10
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
6 changes: 4 additions & 2 deletions dist/esm.dom-bindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,9 @@ function patch(redundant, parentScope) {
return (item, info) => {
if (info < 0) {
const {template, context} = redundant.pop();
template.unmount(context, parentScope, false);
// notice that we pass null as last argument because
// the root node and its children will be removed by domdiff
template.unmount(context, parentScope, null);
}

return item
Expand Down Expand Up @@ -1487,7 +1489,7 @@ const TemplateChunk = Object.freeze({

if (mustRemoveRoot && this.el.parentNode) {
this.el.parentNode.removeChild(this.el);
} else {
} else if (mustRemoveRoot !== null) {
cleanNode(this.el);
}

Expand Down
6 changes: 4 additions & 2 deletions dist/umd.dom-bindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,9 @@
return (item, info) => {
if (info < 0) {
const {template, context} = redundant.pop();
template.unmount(context, parentScope, false);
// notice that we pass null as last argument because
// the root node and its children will be removed by domdiff
template.unmount(context, parentScope, null);
}

return item
Expand Down Expand Up @@ -1493,7 +1495,7 @@

if (mustRemoveRoot && this.el.parentNode) {
this.el.parentNode.removeChild(this.el);
} else {
} else if (mustRemoveRoot !== null) {
cleanNode(this.el);
}

Expand Down
4 changes: 3 additions & 1 deletion src/bindings/each.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ function patch(redundant, parentScope) {
return (item, info) => {
if (info < 0) {
const {template, context} = redundant.pop()
template.unmount(context, parentScope, false)
// notice that we pass null as last argument because
// the root node and its children will be removed by domdiff
template.unmount(context, parentScope, null)
}

return item
Expand Down
2 changes: 1 addition & 1 deletion src/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const TemplateChunk = Object.freeze({

if (mustRemoveRoot && this.el.parentNode) {
this.el.parentNode.removeChild(this.el)
} else {
} else if (mustRemoveRoot !== null) {
cleanNode(this.el)
}

Expand Down

0 comments on commit 3741c10

Please sign in to comment.