native-document 1.0.17-1.6 → 1.0.17-1.7

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": "native-document",
3
- "version": "1.0.171.6",
3
+ "version": "1.0.171.7",
4
4
  "description": "A reactive JavaScript framework that preserves native DOM simplicity without sacrificing modern features",
5
5
  "author": "AfroCodeur <https://github.com/afrocodeur>",
6
6
  "license": "MIT",
@@ -124,6 +124,9 @@ ObservableItem.prototype.triggerListeners = function(operations) {
124
124
  * @param {{ action?: string, args?: any[], result?: any }} [operations] - Mutation metadata
125
125
  */
126
126
  ObservableItem.prototype.triggerWatchers = function(operations) {
127
+ if(!this.$watchers) {
128
+ return;
129
+ }
127
130
  const $watchers = this.$watchers;
128
131
  const $previousValue = this.$previousValue;
129
132
  const $currentValue = this.$currentValue;
@@ -151,14 +151,14 @@ export function ForEachArray(data, callback, configs = {}) {
151
151
  if(Array.isArray(data)) {
152
152
  set = () => {
153
153
  clear(data);
154
- element.appendChildRaw(Actions.toFragment(data));
154
+ Actions.appendToElement(data);
155
155
  };
156
156
  }
157
157
  else {
158
158
  set = () => {
159
159
  const items = data.val();
160
160
  clear(items);
161
- element.appendChildRaw(Actions.toFragment(items));
161
+ Actions.appendToElement(items);
162
162
  };
163
163
  }
164
164
 
@@ -167,45 +167,36 @@ export function ForEachArray(data, callback, configs = {}) {
167
167
  const fragment = document.createDocumentFragment();
168
168
  for(let i = 0, length = items.length; i < length; i++) {
169
169
  fragment.appendChild(buildItem(items[i], lastNumberOfItems));
170
- lastNumberOfItems++;
171
170
  }
172
171
  return fragment;
173
172
  },
173
+ appendToElement: (items) => {
174
+ for(let i = 0, length = items.length; i < length; i++) {
175
+ element.appendChild(buildItem(items[i], i));
176
+ }
177
+ },
174
178
  add: (items) => {
175
- element.appendChildRaw(Actions.toFragment(items));
179
+ Actions.appendToElement(items)
176
180
  },
177
181
  replace: (items) => {
178
182
  clear(items);
179
- element.appendChildRaw(Actions.toFragment(items));
183
+ Actions.appendToElement(items)
180
184
  },
181
185
  set,
182
186
  reOrder: (items) => {
183
187
  let child = null;
184
- const fragment = document.createDocumentFragment();
185
188
  for(const item of items) {
186
189
  child = getItemChild(item);
187
190
  if(child) {
188
- fragment.appendChild(child);
191
+ element.appendChild(child);
189
192
  }
190
193
  }
191
194
  child = null;
192
- element.appendChildRaw(fragment);
193
195
  },
194
196
  removeOne: (element, index) => {
195
197
  removeCacheItem(element, true);
196
198
  },
197
199
  clear,
198
- populate: ([target, iteration, callback]) => {
199
- const fragment = document.createDocumentFragment();
200
- for (let i = 0; i < iteration; i++) {
201
- const data = callback(i);
202
- target.push(data);
203
- fragment.append(buildItem(data, i));
204
- lastNumberOfItems++;
205
- }
206
- element.appendChildRaw(fragment);
207
- fragment.replaceChildren();
208
- },
209
200
  unshift: (values) => {
210
201
  element.insertAtStartRaw(Actions.toFragment(values));
211
202
  },