@webtides/element-js 1.0.0-alpha.7 → 1.0.0-alpha.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webtides/element-js",
3
- "version": "1.0.0-alpha.7",
3
+ "version": "1.0.0-alpha.8",
4
4
  "module": "index.js",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -12,13 +12,13 @@ const removeChildNodes = (node) => {
12
12
  const firstChild = Array.isArray(node)
13
13
  ? node[0]
14
14
  : node instanceof TemplatePart
15
- ? node.childNodes[0]
16
- : node.firstChild;
15
+ ? node.childNodes[0]
16
+ : node.firstChild;
17
17
  const lastChild = Array.isArray(node)
18
18
  ? node[node.length - 1]
19
19
  : node instanceof TemplatePart
20
- ? node.childNodes[node.childNodes.length - 1]
21
- : node.lastChild;
20
+ ? node.childNodes[node.childNodes.length - 1]
21
+ : node.lastChild;
22
22
  range.setStartAfter(firstChild);
23
23
  range.setEndAfter(lastChild);
24
24
  range.deleteContents();
@@ -75,28 +75,12 @@ const diffChildNodes = function (parentNode, domChildNodes, templateChildNodes,
75
75
  }
76
76
 
77
77
  // If DOM node is equal to the template node, don't do anything
78
- // if (domChildNode.isEqualNode(templateChildNode)) {
79
78
  if (domChildNode === templateChildNode) {
80
79
  continue;
81
80
  }
82
81
 
83
- // If node types are not the same, replace the DOM node with the template node
84
- if (templateChildNode.nodeType !== domChildNode.nodeType) {
85
- parentNode.replaceChild(templateChildNode, domChildNode);
86
- continue;
87
- }
88
-
89
- // If the element tag names are not the same, replace the DOM node with the template node
90
- if (templateChildNode.nodeType === ELEMENT_NODE && templateChildNode.tagName !== domChildNode.tagName) {
91
- parentNode.replaceChild(templateChildNode, domChildNode);
92
- continue;
93
- }
94
-
95
- // If the node is an SVG element, don't even think about diffing it, just replace it
96
- if (templateChildNode.nodeType === ELEMENT_NODE && templateChildNode.tagName === 'SVG') {
97
- parentNode.replaceChild(templateChildNode, domChildNode);
98
- continue;
99
- }
82
+ // Everything else is somehow different and can be replaced
83
+ parentNode.replaceChild(templateChildNode, domChildNode);
100
84
  }
101
85
  return templateChildNodes;
102
86
  };