Skip to content

Commit

Permalink
Release 2.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismccord committed Jan 31, 2023
1 parent 332fd79 commit 8d0d475
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 44 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Changelog

# 2.x

## 2.6.2
## 2.7.0

- Add new `addChild` and `skipFromChildren` callbacks to allow customization of how new children are
added to a parent as well as preserving the from tree when indexing changes for diffing.
Expand Down
62 changes: 31 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,37 +100,37 @@ Supported options (all optional):
```javascript
var morphdom = require('morphdom');
var morphedNode = morphdom(fromNode, toNode, {
getNodeKey: function(node) {
return node.id;
},
addChild: function(parentNode, childNode) {
parentNode.appendChild(childNode);
},
onBeforeNodeAdded: function(node) {
return node;
},
onNodeAdded: function(node) {

},
onBeforeElUpdated: function(fromEl, toEl) {
return true;
},
onElUpdated: function(el) {

},
onBeforeNodeDiscarded: function(node) {
return true;
},
onNodeDiscarded: function(node) {

},
onBeforeElChildrenUpdated: function(fromEl, toEl) {
return true;
},
childrenOnly: false,
skipFromChildren: function(fromEl) {
return false;
}
getNodeKey: function(node) {
return node.id;
},
addChild: function(parentNode, childNode) {
parentNode.appendChild(childNode);
},
onBeforeNodeAdded: function(node) {
return node;
},
onNodeAdded: function(node) {

},
onBeforeElUpdated: function(fromEl, toEl) {
return true;
},
onElUpdated: function(el) {

},
onBeforeNodeDiscarded: function(node) {
return true;
},
onNodeDiscarded: function(node) {

},
onBeforeElChildrenUpdated: function(fromEl, toEl) {
return true;
},
childrenOnly: false,
skipFromChildren: function(fromEl) {
return false;
}
});
```

Expand Down
5 changes: 3 additions & 2 deletions dist/morphdom-esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -649,10 +649,11 @@ function morphdomFactory(morphAttrs) {

// If we got this far then we did not find a candidate match for
// our "to node" and we exhausted all of the children "from"
// nodes.
// nodes. Therefore, we will just append the current "to" node
// to the end
if (curToNodeKey && (matchingFromEl = fromNodesLookup[curToNodeKey]) && compareNodeNames(matchingFromEl, curToNodeChild)) {
// MORPH
addChild(fromEl, matchingFromEl);
if(!skipFrom){ addChild(fromEl, matchingFromEl); }
morphEl(matchingFromEl, curToNodeChild);
} else {
var onBeforeNodeAddedResult = onBeforeNodeAdded(curToNodeChild);
Expand Down
5 changes: 3 additions & 2 deletions dist/morphdom-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -587,10 +587,11 @@ function morphdomFactory(morphAttrs) {

// If we got this far then we did not find a candidate match for
// our "to node" and we exhausted all of the children "from"
// nodes.
// nodes. Therefore, we will just append the current "to" node
// to the end
if (curToNodeKey && (matchingFromEl = fromNodesLookup[curToNodeKey]) && compareNodeNames(matchingFromEl, curToNodeChild)) {
// MORPH
addChild(fromEl, matchingFromEl);
if(!skipFrom){ addChild(fromEl, matchingFromEl); }
morphEl(matchingFromEl, curToNodeChild);
} else {
var onBeforeNodeAddedResult = onBeforeNodeAdded(curToNodeChild);
Expand Down
5 changes: 3 additions & 2 deletions dist/morphdom-umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -655,10 +655,11 @@

// If we got this far then we did not find a candidate match for
// our "to node" and we exhausted all of the children "from"
// nodes.
// nodes. Therefore, we will just append the current "to" node
// to the end
if (curToNodeKey && (matchingFromEl = fromNodesLookup[curToNodeKey]) && compareNodeNames(matchingFromEl, curToNodeChild)) {
// MORPH
addChild(fromEl, matchingFromEl);
if(!skipFrom){ addChild(fromEl, matchingFromEl); }
morphEl(matchingFromEl, curToNodeChild);
} else {
var onBeforeNodeAddedResult = onBeforeNodeAdded(curToNodeChild);
Expand Down
2 changes: 1 addition & 1 deletion dist/morphdom-umd.min.js

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions dist/morphdom.js
Original file line number Diff line number Diff line change
Expand Up @@ -651,10 +651,11 @@ function morphdomFactory(morphAttrs) {

// If we got this far then we did not find a candidate match for
// our "to node" and we exhausted all of the children "from"
// nodes.
// nodes. Therefore, we will just append the current "to" node
// to the end
if (curToNodeKey && (matchingFromEl = fromNodesLookup[curToNodeKey]) && compareNodeNames(matchingFromEl, curToNodeChild)) {
// MORPH
addChild(fromEl, matchingFromEl);
if(!skipFrom){ addChild(fromEl, matchingFromEl); }
morphEl(matchingFromEl, curToNodeChild);
} else {
var onBeforeNodeAddedResult = onBeforeNodeAdded(curToNodeChild);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"virtual-dom": "^2.1.1"
},
"dependencies": {},
"version": "2.6.2",
"version": "2.7.0",
"keywords": [
"dom",
"diff",
Expand Down
5 changes: 3 additions & 2 deletions src/morphdom.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,10 +365,11 @@ export default function morphdomFactory(morphAttrs) {

// If we got this far then we did not find a candidate match for
// our "to node" and we exhausted all of the children "from"
// nodes.
// nodes. Therefore, we will just append the current "to" node
// to the end
if (curToNodeKey && (matchingFromEl = fromNodesLookup[curToNodeKey]) && compareNodeNames(matchingFromEl, curToNodeChild)) {
// MORPH
addChild(fromEl, matchingFromEl);
if(!skipFrom){ addChild(fromEl, matchingFromEl); }
morphEl(matchingFromEl, curToNodeChild);
} else {
var onBeforeNodeAddedResult = onBeforeNodeAdded(curToNodeChild);
Expand Down

0 comments on commit 8d0d475

Please sign in to comment.