@lengkapp/edge 0.0.5 → 0.0.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/edge-client.js +265 -246
- package/package.json +1 -1
package/edge-client.js
CHANGED
|
@@ -1,284 +1,303 @@
|
|
|
1
|
-
(()
|
|
2
|
-
|
|
1
|
+
(function () {
|
|
2
|
+
if (window.__edge) return;
|
|
3
|
+
window.__edge = true;
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
body = d.body,
|
|
6
|
-
head = d.head;
|
|
5
|
+
var d = document, head = d.head, root = d.documentElement;
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
var METHODS = ['get', 'post', 'put', 'patch', 'delete'];
|
|
8
|
+
var METHOD_ATTRS = METHODS.map(function (m) { return '_' + m; });
|
|
9
|
+
var HAS_BODY = { post: 1, put: 1, patch: 1 };
|
|
10
|
+
var SEL = METHOD_ATTRS.map(function (a) { return '[' + a + ']'; }).join(',');
|
|
11
|
+
|
|
12
|
+
var DELEGATABLE = new Set([
|
|
10
13
|
'click', 'dblclick', 'mousedown', 'mouseup', 'mouseover', 'mouseout',
|
|
11
|
-
'
|
|
12
|
-
'
|
|
13
|
-
'
|
|
14
|
-
'change', 'input', 'submit', 'reset',
|
|
15
|
-
'load', 'DOMContentLoaded', 'ready',
|
|
16
|
-
'scroll', 'resize', 'wheel', 'touchstart', 'touchend', 'touchmove',
|
|
17
|
-
'visible', 'intersect'
|
|
14
|
+
'mousemove', 'contextmenu', 'focusin', 'focusout', 'keydown', 'keyup',
|
|
15
|
+
'keypress', 'change', 'input', 'submit', 'reset', 'wheel',
|
|
16
|
+
'touchstart', 'touchend', 'touchmove'
|
|
18
17
|
]);
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
var bound = new WeakSet();
|
|
20
|
+
var running = new WeakSet();
|
|
21
|
+
var targetCache = new WeakMap();
|
|
22
|
+
var wasVisible = new WeakMap();
|
|
23
|
+
var ioObservers = new Map();
|
|
24
|
+
var injected = new Set();
|
|
25
|
+
var executedSrc = new Set();
|
|
26
|
+
|
|
27
|
+
var style = d.createElement('style');
|
|
28
|
+
style.textContent =
|
|
29
|
+
'.aj-skel-wrap{box-sizing:border-box;width:100%;height:100%;min-width:80px;min-height:48px;' +
|
|
30
|
+
'max-width:100%;max-height:600px;display:flex;align-items:center;justify-content:center}' +
|
|
31
|
+
'.aj-skel-wrap svg{width:1.75em;height:1.75em;color:#c7c7c7;' +
|
|
32
|
+
'animation:aj-pulse 1.4s ease-in-out infinite}' +
|
|
33
|
+
'@keyframes aj-pulse{0%,100%{opacity:.35;transform:scale(.92)}50%{opacity:1;transform:scale(1)}}' +
|
|
34
|
+
'.aj-retry-wrap{box-sizing:border-box;width:100%;height:100%;min-width:80px;min-height:48px;' +
|
|
35
|
+
'max-height:600px;display:flex;align-items:center;justify-content:center}' +
|
|
36
|
+
'.aj-retry{width:2.5em;height:2.5em;padding:0;cursor:pointer;background:#007bff;color:#fff;' +
|
|
37
|
+
'border:0;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;' +
|
|
38
|
+
'transition:background .15s ease}' +
|
|
39
|
+
'.aj-retry:hover{background:#0056b3}' +
|
|
40
|
+
'.aj-retry:hover svg{transform:rotate(-90deg)}' +
|
|
41
|
+
'.aj-retry svg{width:1.25em;height:1.25em;transition:transform .3s ease}';
|
|
42
|
+
head.appendChild(style);
|
|
24
43
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
.
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
background-position: -200% 0;
|
|
44
|
+
function cfg(el) {
|
|
45
|
+
var attr = null;
|
|
46
|
+
for (var i = 0; i < METHOD_ATTRS.length; i++) {
|
|
47
|
+
if (el.hasAttribute(METHOD_ATTRS[i])) { attr = METHOD_ATTRS[i]; break; }
|
|
48
|
+
}
|
|
49
|
+
if (!attr) return null;
|
|
50
|
+
var method = attr.slice(1);
|
|
51
|
+
return {
|
|
52
|
+
url: el.getAttribute(attr),
|
|
53
|
+
method: method.toUpperCase(),
|
|
54
|
+
hasBody: !!HAS_BODY[method],
|
|
55
|
+
target: el.getAttribute('_target'),
|
|
56
|
+
trigger: el.getAttribute('_trigger'),
|
|
57
|
+
form: el.getAttribute('_form'),
|
|
58
|
+
json: el.getAttribute('_json'),
|
|
59
|
+
skeleton: el.getAttribute('_skeleton') !== 'false',
|
|
60
|
+
retry: el.getAttribute('_retry') !== 'false'
|
|
61
|
+
};
|
|
44
62
|
}
|
|
45
|
-
|
|
46
|
-
|
|
63
|
+
|
|
64
|
+
function resolveTarget(el, c) {
|
|
65
|
+
if (!c.target || c.target === 'this') return el;
|
|
66
|
+
var cached = targetCache.get(el);
|
|
67
|
+
if (cached && cached.isConnected) return cached;
|
|
68
|
+
var found = d.querySelector(c.target);
|
|
69
|
+
if (found) targetCache.set(el, found);
|
|
70
|
+
return found;
|
|
47
71
|
}
|
|
48
|
-
}
|
|
49
72
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
.df-retry:hover { background:#0056b3; }
|
|
55
|
-
`;
|
|
56
|
-
head.appendChild(style);
|
|
57
|
-
};
|
|
58
|
-
injectBaseStyles();
|
|
73
|
+
function triggersFor(c) {
|
|
74
|
+
return (c.trigger || (c.target === 'this' ? 'load' : 'click'))
|
|
75
|
+
.split(',').map(function (s) { return s.trim().toLowerCase(); });
|
|
76
|
+
}
|
|
59
77
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
78
|
+
function isActuallyVisible(el) {
|
|
79
|
+
var s = getComputedStyle(el);
|
|
80
|
+
if (s.display === 'none' || s.visibility === 'hidden' || s.opacity === '0') return false;
|
|
81
|
+
var r = el.getBoundingClientRect();
|
|
82
|
+
return r.width > 0 && r.height > 0;
|
|
83
|
+
}
|
|
66
84
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
};
|
|
85
|
+
var SKELETON_ICON =
|
|
86
|
+
'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" ' +
|
|
87
|
+
'fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" ' +
|
|
88
|
+
'stroke-linejoin="round" aria-hidden="true">' +
|
|
89
|
+
'<path d="m12 14 4-4"/><path d="M3.34 19a10 10 0 1 1 17.32 0"/>' +
|
|
90
|
+
'</svg>';
|
|
74
91
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
resourceCache.add(url);
|
|
79
|
-
if (type === 'css') {
|
|
80
|
-
const link = d.createElement('link');
|
|
81
|
-
link.rel = 'stylesheet'; link.href = url;
|
|
82
|
-
head.appendChild(link);
|
|
83
|
-
} else if (type === 'js') {
|
|
84
|
-
const script = d.createElement('script');
|
|
85
|
-
script.src = url;
|
|
86
|
-
body.appendChild(script);
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
};
|
|
92
|
+
function showSkeleton(el) {
|
|
93
|
+
el.innerHTML = '<div class="aj-skel-wrap">' + SKELETON_ICON + '</div>';
|
|
94
|
+
}
|
|
90
95
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
};
|
|
96
|
+
var RETRY_ICON =
|
|
97
|
+
'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" ' +
|
|
98
|
+
'fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" ' +
|
|
99
|
+
'stroke-linejoin="round" aria-hidden="true">' +
|
|
100
|
+
'<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><path d="M3 3v5h5"/>' +
|
|
101
|
+
'</svg>';
|
|
98
102
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}, { threshold: 0 });
|
|
113
|
-
}
|
|
114
|
-
return intersectionObserver;
|
|
115
|
-
};
|
|
103
|
+
function showRetry(el, fn) {
|
|
104
|
+
el.innerHTML = '';
|
|
105
|
+
var wrap = d.createElement('div');
|
|
106
|
+
wrap.className = 'aj-retry-wrap';
|
|
107
|
+
var b = d.createElement('button');
|
|
108
|
+
b.type = 'button';
|
|
109
|
+
b.className = 'aj-retry';
|
|
110
|
+
b.setAttribute('aria-label', 'Retry');
|
|
111
|
+
b.innerHTML = RETRY_ICON;
|
|
112
|
+
b.addEventListener('click', fn, { once: true });
|
|
113
|
+
wrap.appendChild(b);
|
|
114
|
+
el.appendChild(wrap);
|
|
115
|
+
}
|
|
116
116
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
117
|
+
function parseList(raw) {
|
|
118
|
+
if (!raw) return [];
|
|
119
|
+
return raw.replace(/^\[|\]$/g, '').split(',')
|
|
120
|
+
.map(function (s) { return s.trim().replace(/^['"]|['"]$/g, ''); })
|
|
121
|
+
.filter(Boolean);
|
|
122
|
+
}
|
|
121
123
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
124
|
+
function injectResources(headers) {
|
|
125
|
+
parseList(headers.get('x-css-required')).forEach(function (url) {
|
|
126
|
+
if (injected.has(url)) return;
|
|
127
|
+
injected.add(url);
|
|
128
|
+
var link = d.createElement('link');
|
|
129
|
+
link.rel = 'stylesheet'; link.href = url;
|
|
130
|
+
head.appendChild(link);
|
|
131
|
+
});
|
|
132
|
+
parseList(headers.get('x-js-required')).forEach(function (url) {
|
|
133
|
+
if (injected.has(url)) return;
|
|
134
|
+
injected.add(url);
|
|
135
|
+
var s = d.createElement('script');
|
|
136
|
+
s.src = url;
|
|
137
|
+
head.appendChild(s);
|
|
138
|
+
});
|
|
139
|
+
}
|
|
125
140
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
));
|
|
139
|
-
|
|
141
|
+
function execScripts(container) {
|
|
142
|
+
var scripts = Array.prototype.slice.call(container.querySelectorAll('script'));
|
|
143
|
+
var i = 0;
|
|
144
|
+
function next() {
|
|
145
|
+
if (i >= scripts.length) return;
|
|
146
|
+
var old = scripts[i];
|
|
147
|
+
var s = d.createElement('script');
|
|
148
|
+
for (var a = 0; a < old.attributes.length; a++) {
|
|
149
|
+
s.setAttribute(old.attributes[a].name, old.attributes[a].value);
|
|
150
|
+
}
|
|
151
|
+
if (old.nonce) s.nonce = old.nonce;
|
|
152
|
+
if (old.src) {
|
|
153
|
+
if (executedSrc.has(old.src)) { old.remove(); i++; next(); return; }
|
|
154
|
+
executedSrc.add(old.src);
|
|
155
|
+
s.onload = s.onerror = function () { i++; next(); };
|
|
156
|
+
old.replaceWith(s);
|
|
157
|
+
} else {
|
|
158
|
+
s.textContent = '{\n' + old.textContent + '\n}';
|
|
159
|
+
old.replaceWith(s);
|
|
160
|
+
i++; next();
|
|
140
161
|
}
|
|
141
162
|
}
|
|
163
|
+
next();
|
|
164
|
+
}
|
|
142
165
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
if (container) targetCache.set(el, container);
|
|
149
|
-
}
|
|
150
|
-
if (!container) {
|
|
151
|
-
console.warn('Target not found:', targetSelector);
|
|
152
|
-
el.dataset.running = 'false';
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
container.replaceChildren(skeletonTemplate.content.cloneNode(true));
|
|
157
|
-
|
|
158
|
-
try {
|
|
159
|
-
const res = await fetch(url, { method: post ? 'POST' : 'GET', body: bodyData, headers });
|
|
166
|
+
function setContent(el, html) {
|
|
167
|
+
el.innerHTML = html;
|
|
168
|
+
execScripts(el);
|
|
169
|
+
bind(el);
|
|
170
|
+
}
|
|
160
171
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
if (css) injectResources(parseHeaderList(css), 'css');
|
|
165
|
-
if (js) injectResources(parseHeaderList(js), 'js');
|
|
172
|
+
function doFetch(el, c) {
|
|
173
|
+
if (running.has(el)) return;
|
|
174
|
+
running.add(el);
|
|
166
175
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
console.error(err);
|
|
171
|
-
// Show retry (clone template)
|
|
172
|
-
const retry = retryTemplate.content.firstElementChild.cloneNode(true);
|
|
173
|
-
retry.addEventListener('click', (e) => {
|
|
174
|
-
e.preventDefault();
|
|
175
|
-
e.stopPropagation();
|
|
176
|
-
run(el);
|
|
177
|
-
});
|
|
178
|
-
container.replaceChildren(retry);
|
|
179
|
-
} finally {
|
|
180
|
-
el.dataset.running = 'false';
|
|
181
|
-
}
|
|
182
|
-
};
|
|
176
|
+
var target = resolveTarget(el, c);
|
|
177
|
+
if (!target) { running.delete(el); return; }
|
|
178
|
+
if (c.skeleton) showSkeleton(target);
|
|
183
179
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
180
|
+
var opts = { method: c.method };
|
|
181
|
+
if (c.hasBody) {
|
|
182
|
+
if (c.json) {
|
|
183
|
+
var obj = {};
|
|
184
|
+
c.json.split(',').forEach(function (name) {
|
|
185
|
+
name = name.trim();
|
|
186
|
+
var input = d.querySelector('[name="' + name + '"]');
|
|
187
|
+
obj[name] = input ? input.value : undefined;
|
|
188
|
+
});
|
|
189
|
+
opts.headers = { 'Content-Type': 'application/json' };
|
|
190
|
+
opts.body = JSON.stringify(obj);
|
|
191
|
+
} else if (c.form) {
|
|
192
|
+
var form = d.getElementById(c.form);
|
|
193
|
+
opts.headers = { 'Content-Type': 'application/x-www-form-urlencoded' };
|
|
194
|
+
opts.body = form ? new URLSearchParams(new FormData(form)).toString() : '';
|
|
195
|
+
}
|
|
199
196
|
}
|
|
200
|
-
triggerCache.set(el, events);
|
|
201
|
-
return events;
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
// ---------- Element initialisation (no per‑element listeners) ----------
|
|
205
|
-
const initElement = (el) => {
|
|
206
|
-
if (el.dataset.initialized === 'true') return;
|
|
207
|
-
el.dataset.initialized = 'true';
|
|
208
197
|
|
|
209
|
-
|
|
198
|
+
fetch(c.url, opts)
|
|
199
|
+
.then(function (res) {
|
|
200
|
+
if (!res.ok) throw new Error('HTTP ' + res.status);
|
|
201
|
+
injectResources(res.headers);
|
|
202
|
+
return res.text();
|
|
203
|
+
})
|
|
204
|
+
.then(function (html) { setContent(target, html); })
|
|
205
|
+
.catch(function (err) {
|
|
206
|
+
console.error(err);
|
|
207
|
+
if (c.retry) showRetry(target, function () { doFetch(el, c); });
|
|
208
|
+
})
|
|
209
|
+
.finally(function () { running.delete(el); });
|
|
210
|
+
}
|
|
210
211
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
212
|
+
var delegationInit = false;
|
|
213
|
+
function initDelegation() {
|
|
214
|
+
if (delegationInit) return;
|
|
215
|
+
delegationInit = true;
|
|
216
|
+
DELEGATABLE.forEach(function (evt) {
|
|
217
|
+
var isClickOrSubmit = evt === 'click' || evt === 'submit';
|
|
218
|
+
d.addEventListener(evt, function (e) {
|
|
219
|
+
var t = e.target;
|
|
220
|
+
if (!(t instanceof Element)) return;
|
|
221
|
+
var el = t.closest(SEL);
|
|
222
|
+
if (!el) return;
|
|
223
|
+
var c = cfg(el);
|
|
224
|
+
if (!c || triggersFor(c).indexOf(evt) === -1) return;
|
|
225
|
+
if (isClickOrSubmit) e.preventDefault();
|
|
226
|
+
doFetch(el, c);
|
|
227
|
+
}, isClickOrSubmit ? false : { passive: true });
|
|
228
|
+
});
|
|
229
|
+
}
|
|
222
230
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
'keydown', 'keyup', 'keypress',
|
|
229
|
-
'change', 'input', 'submit', 'reset',
|
|
230
|
-
'scroll', 'resize', 'wheel', 'touchstart', 'touchend', 'touchmove'
|
|
231
|
-
]);
|
|
231
|
+
function bindOne(el) {
|
|
232
|
+
if (bound.has(el)) return;
|
|
233
|
+
bound.add(el);
|
|
234
|
+
var c = cfg(el);
|
|
235
|
+
if (!c) return;
|
|
232
236
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
237
|
+
triggersFor(c).forEach(function (trig) {
|
|
238
|
+
if (trig === 'load' || trig === 'domcontentloaded' || trig === 'ready') {
|
|
239
|
+
queueMicrotask(function () { doFetch(el, c); });
|
|
240
|
+
} else if (trig === 'visible' || trig === 'intersect') {
|
|
241
|
+
wasVisible.set(el, false);
|
|
242
|
+
var obs = new IntersectionObserver(function (entries) {
|
|
243
|
+
entries.forEach(function (entry) {
|
|
244
|
+
if (!entry.target.isConnected) { obs.disconnect(); ioObservers.delete(el); return; }
|
|
245
|
+
var vis = entry.isIntersecting && isActuallyVisible(el);
|
|
246
|
+
if (vis && !wasVisible.get(el)) doFetch(el, c);
|
|
247
|
+
wasVisible.set(el, vis);
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
obs.observe(el);
|
|
251
|
+
ioObservers.set(el, obs);
|
|
252
|
+
} else if (!DELEGATABLE.has(trig)) {
|
|
253
|
+
el.addEventListener(trig, function () { doFetch(el, c); });
|
|
245
254
|
}
|
|
246
|
-
}
|
|
247
|
-
}
|
|
255
|
+
});
|
|
256
|
+
}
|
|
248
257
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
258
|
+
function bind(subtreeRoot) {
|
|
259
|
+
if (subtreeRoot.nodeType !== 1) return;
|
|
260
|
+
if (subtreeRoot.matches && subtreeRoot.matches(SEL)) bindOne(subtreeRoot);
|
|
261
|
+
if (subtreeRoot.querySelectorAll) subtreeRoot.querySelectorAll(SEL).forEach(bindOne);
|
|
262
|
+
}
|
|
252
263
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
264
|
+
function cleanup(removedRoot) {
|
|
265
|
+
if (!ioObservers.size) return;
|
|
266
|
+
ioObservers.forEach(function (obs, el) {
|
|
267
|
+
if (removedRoot === el || removedRoot.contains(el)) {
|
|
268
|
+
obs.disconnect();
|
|
269
|
+
ioObservers.delete(el);
|
|
270
|
+
bound.delete(el);
|
|
271
|
+
}
|
|
261
272
|
});
|
|
262
|
-
}
|
|
273
|
+
}
|
|
263
274
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
275
|
+
var addQueue = new Set(), removeQueue = new Set(), flushScheduled = false;
|
|
276
|
+
function flush() {
|
|
277
|
+
flushScheduled = false;
|
|
278
|
+
var adds = Array.from(addQueue); addQueue.clear();
|
|
279
|
+
var rems = Array.from(removeQueue); removeQueue.clear();
|
|
280
|
+
adds.forEach(bind);
|
|
281
|
+
rems.forEach(cleanup);
|
|
282
|
+
}
|
|
283
|
+
function scheduleFlush() {
|
|
284
|
+
if (flushScheduled) return;
|
|
285
|
+
flushScheduled = true;
|
|
286
|
+
queueMicrotask(flush);
|
|
287
|
+
}
|
|
276
288
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
289
|
+
new MutationObserver(function (mutations) {
|
|
290
|
+
mutations.forEach(function (m) {
|
|
291
|
+
m.addedNodes.forEach(function (n) { if (n.nodeType === 1) addQueue.add(n); });
|
|
292
|
+
m.removedNodes.forEach(function (n) { if (n.nodeType === 1) removeQueue.add(n); });
|
|
293
|
+
});
|
|
294
|
+
scheduleFlush();
|
|
295
|
+
}).observe(root, { childList: true, subtree: true });
|
|
281
296
|
|
|
297
|
+
function initAll() {
|
|
298
|
+
initDelegation();
|
|
299
|
+
bind(root);
|
|
300
|
+
}
|
|
282
301
|
if (d.readyState === 'loading') {
|
|
283
302
|
d.addEventListener('DOMContentLoaded', initAll, { once: true });
|
|
284
303
|
} else {
|