native-document 1.0.17-1.5 → 1.0.17-1.6
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.
|
|
3
|
+
"version": "1.0.171.6",
|
|
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",
|
|
@@ -65,7 +65,7 @@ export function ForEachArray(data, callback, configs = {}) {
|
|
|
65
65
|
throw new NativeDocumentError('ForEachArray child can\'t be null or undefined!');
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
-
cache.set(item,
|
|
68
|
+
cache.set(item, child);
|
|
69
69
|
return child;
|
|
70
70
|
};
|
|
71
71
|
|
|
@@ -77,7 +77,7 @@ export function ForEachArray(data, callback, configs = {}) {
|
|
|
77
77
|
throw new NativeDocumentError('ForEachArray child can\'t be null or undefined!');
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
-
cache.set(item,
|
|
80
|
+
cache.set(item, child, indexObserver);
|
|
81
81
|
return child;
|
|
82
82
|
};
|
|
83
83
|
if(!data.__$Observable) {
|
|
@@ -88,7 +88,7 @@ export function ForEachArray(data, callback, configs = {}) {
|
|
|
88
88
|
throw new NativeDocumentError('ForEachArray child can\'t be null or undefined!');
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
|
-
cache.set(item,
|
|
91
|
+
cache.set(item, child);
|
|
92
92
|
return child;
|
|
93
93
|
};
|
|
94
94
|
}
|
|
@@ -204,15 +204,13 @@ NDElement.prototype.destroy = function() {
|
|
|
204
204
|
for(let i = 0, length = nodes.length; i < length; i++) {
|
|
205
205
|
const child = nodes[i];
|
|
206
206
|
child.remove();
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
$lifeCycleObservers.delete(child);
|
|
207
|
+
const childObserver = $lifeCycleObservers.get(child);
|
|
208
|
+
if(childObserver) {
|
|
209
|
+
childObserver.disconnect();
|
|
211
210
|
}
|
|
211
|
+
$lifeCycleObservers.delete(child);
|
|
212
212
|
}
|
|
213
213
|
|
|
214
|
-
this.$element.__$controller?.abort();
|
|
215
|
-
this.$element.__$controller = null;
|
|
216
214
|
$lifeCycleObservers.delete(this.$element);
|
|
217
215
|
this.$element.remove();
|
|
218
216
|
this.$element = null;
|
|
@@ -636,7 +634,7 @@ NDElement.prototype.contentEditable = function($obs, {format = 'html'} = {}) {
|
|
|
636
634
|
|
|
637
635
|
this.$element.addEventListener('input', () => {
|
|
638
636
|
$obs?.set(getValue());
|
|
639
|
-
}
|
|
637
|
+
});
|
|
640
638
|
|
|
641
639
|
return this;
|
|
642
640
|
};
|
|
@@ -27,10 +27,7 @@ Object.defineProperty(NDElement.prototype, 'nd', {
|
|
|
27
27
|
EVENTS.forEach(eventSourceName => {
|
|
28
28
|
const eventName = eventSourceName.toLowerCase();
|
|
29
29
|
NDElement.prototype['on'+eventSourceName] = function(callback = null, options = {}) {
|
|
30
|
-
this.$element.addEventListener(eventName, callback,
|
|
31
|
-
signal: this.$getSignal(),
|
|
32
|
-
...options,
|
|
33
|
-
});
|
|
30
|
+
this.$element.addEventListener(eventName, callback, options);
|
|
34
31
|
return this;
|
|
35
32
|
};
|
|
36
33
|
});
|
|
@@ -38,17 +35,11 @@ EVENTS.forEach(eventSourceName => {
|
|
|
38
35
|
EVENTS_WITH_STOP.forEach(eventSourceName => {
|
|
39
36
|
const eventName = eventSourceName.toLowerCase();
|
|
40
37
|
NDElement.prototype['onStop'+eventSourceName] = function(callback = null, options = {}) {
|
|
41
|
-
_stop(this.$element, eventName, callback,
|
|
42
|
-
signal: this.$getSignal(),
|
|
43
|
-
...options,
|
|
44
|
-
});
|
|
38
|
+
_stop(this.$element, eventName, callback, options);
|
|
45
39
|
return this;
|
|
46
40
|
};
|
|
47
41
|
NDElement.prototype['onPreventStop'+eventSourceName] = function(callback = null, options = {}) {
|
|
48
|
-
_preventStop(this.$element, eventName, callback,
|
|
49
|
-
signal: this.$getSignal(),
|
|
50
|
-
...options,
|
|
51
|
-
});
|
|
42
|
+
_preventStop(this.$element, eventName, callback, options);
|
|
52
43
|
return this;
|
|
53
44
|
};
|
|
54
45
|
});
|
|
@@ -56,29 +47,11 @@ EVENTS_WITH_STOP.forEach(eventSourceName => {
|
|
|
56
47
|
EVENTS_WITH_PREVENT.forEach(eventSourceName => {
|
|
57
48
|
const eventName = eventSourceName.toLowerCase();
|
|
58
49
|
NDElement.prototype['onPrevent'+eventSourceName] = function(callback = null, options = {}) {
|
|
59
|
-
_prevent(this.$element, eventName, callback,
|
|
60
|
-
signal: this.$getSignal(),
|
|
61
|
-
...options,
|
|
62
|
-
});
|
|
50
|
+
_prevent(this.$element, eventName, callback, options);
|
|
63
51
|
return this;
|
|
64
52
|
};
|
|
65
53
|
});
|
|
66
54
|
|
|
67
|
-
/**
|
|
68
|
-
* Retrieves or creates an AbortController signal tied to this element's lifecycle.
|
|
69
|
-
* The signal is automatically aborted when the element is removed via .nd.remove().
|
|
70
|
-
* Used internally by all event listeners (onClick, onInput, etc.) to auto-cleanup on unmount.
|
|
71
|
-
*
|
|
72
|
-
* @internal
|
|
73
|
-
* @returns {AbortSignal} The signal for this element's AbortController
|
|
74
|
-
*/
|
|
75
|
-
NDElement.prototype.$getSignal = function() {
|
|
76
|
-
if(!this.$element.__$controller) {
|
|
77
|
-
// this.$element.__$controller = new AbortController();
|
|
78
|
-
}
|
|
79
|
-
return this.$element.__$controller.signal;
|
|
80
|
-
};
|
|
81
|
-
|
|
82
55
|
|
|
83
56
|
/**
|
|
84
57
|
* Adds a native event listener to the underlying HTMLElement.
|
|
@@ -91,7 +64,6 @@ NDElement.prototype.$getSignal = function() {
|
|
|
91
64
|
*/
|
|
92
65
|
NDElement.prototype.on = function(name, callback, options) {
|
|
93
66
|
this.$element.addEventListener(name.toLowerCase(), callback, {
|
|
94
|
-
signal: this.$getSignal(),
|
|
95
67
|
...options,
|
|
96
68
|
});
|
|
97
69
|
return this;
|
|
@@ -119,7 +91,6 @@ NDElement.prototype.off = function(name, callback) {
|
|
|
119
91
|
*/
|
|
120
92
|
NDElement.prototype.once = function(name, callback) {
|
|
121
93
|
this.$element.addEventListener(name.toLowerCase(), callback, {
|
|
122
|
-
signal: this.$getSignal(),
|
|
123
94
|
once: true,
|
|
124
95
|
});
|
|
125
96
|
return this;
|