@xtia/jel 0.6.2 → 0.6.3

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.
Files changed (2) hide show
  1. package/internal/element.js +16 -10
  2. package/package.json +1 -1
@@ -103,17 +103,23 @@ function observeMutations() {
103
103
  if (mutationObserver !== null)
104
104
  return;
105
105
  mutationObserver = new MutationObserver((mutations) => {
106
+ const recursiveAdd = (node) => {
107
+ if (elementMutationMap.has(node)) {
108
+ elementMutationMap.get(node).add();
109
+ }
110
+ if (node.hasChildNodes())
111
+ node.childNodes.forEach(recursiveAdd);
112
+ };
113
+ const recursiveRemove = (node) => {
114
+ if (elementMutationMap.has(node)) {
115
+ elementMutationMap.get(node).remove();
116
+ }
117
+ if (node.hasChildNodes())
118
+ node.childNodes.forEach(recursiveRemove);
119
+ };
106
120
  mutations.forEach(mut => {
107
- mut.addedNodes.forEach(node => {
108
- if (elementMutationMap.has(node)) {
109
- elementMutationMap.get(node).add();
110
- }
111
- });
112
- mut.removedNodes.forEach(node => {
113
- if (elementMutationMap.has(node)) {
114
- elementMutationMap.get(node).remove();
115
- }
116
- });
121
+ mut.addedNodes.forEach(node => recursiveAdd(node));
122
+ mut.removedNodes.forEach(node => recursiveRemove(node));
117
123
  });
118
124
  });
119
125
  mutationObserver.observe(document.body, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xtia/jel",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
4
4
  "repository": {
5
5
  "url": "https://github.com/tiadrop/jel-ts",
6
6
  "type": "github"