what-core 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.
- package/README.md +2 -0
- package/compiler.d.ts +30 -0
- package/devtools.d.ts +2 -0
- package/dist/compiler.js +1787 -0
- package/dist/compiler.js.map +7 -0
- package/dist/compiler.min.js +2 -0
- package/dist/compiler.min.js.map +7 -0
- package/dist/devtools.js +10 -0
- package/dist/devtools.js.map +7 -0
- package/dist/devtools.min.js +2 -0
- package/dist/devtools.min.js.map +7 -0
- package/dist/index.js +330 -382
- package/dist/index.js.map +4 -4
- package/dist/index.min.js +62 -62
- package/dist/index.min.js.map +4 -4
- package/dist/render.js +262 -21
- package/dist/render.js.map +4 -4
- package/dist/render.min.js +58 -1
- package/dist/render.min.js.map +4 -4
- package/dist/testing.js +3 -0
- package/dist/testing.js.map +2 -2
- package/dist/testing.min.js +1 -1
- package/dist/testing.min.js.map +2 -2
- package/index.d.ts +176 -1
- package/jsx-runtime.d.ts +622 -0
- package/package.json +20 -2
- package/src/agent-context.js +1 -1
- package/src/compiler.js +18 -0
- package/src/components.js +73 -27
- package/src/devtools.js +4 -0
- package/src/dom.js +7 -0
- package/src/guardrails.js +3 -4
- package/src/hooks.js +0 -11
- package/src/index.js +5 -9
- package/src/render.js +91 -24
- package/dist/a11y.js +0 -440
- package/dist/animation.js +0 -548
- package/dist/components.js +0 -229
- package/dist/data.js +0 -638
- package/dist/dom.js +0 -439
- package/dist/form.js +0 -509
- package/dist/h.js +0 -152
- package/dist/head.js +0 -51
- package/dist/helpers.js +0 -140
- package/dist/hooks.js +0 -210
- package/dist/reactive.js +0 -432
- package/dist/scheduler.js +0 -246
- package/dist/skeleton.js +0 -363
- package/dist/store.js +0 -83
- package/dist/what.js +0 -117
package/dist/dom.js
DELETED
|
@@ -1,439 +0,0 @@
|
|
|
1
|
-
import { effect, batch, untrack, signal, __DEV__, __devtools } from './reactive.js';
|
|
2
|
-
import { reportError, _injectGetCurrentComponent, shallowEqual } from './components.js';
|
|
3
|
-
import { _setComponentRef } from './helpers.js';
|
|
4
|
-
const SVG_ELEMENTS = new Set([
|
|
5
|
-
'svg', 'path', 'circle', 'rect', 'line', 'polyline', 'polygon', 'ellipse',
|
|
6
|
-
'g', 'defs', 'use', 'symbol', 'clipPath', 'mask', 'pattern', 'image',
|
|
7
|
-
'text', 'tspan', 'textPath', 'foreignObject', 'linearGradient', 'radialGradient', 'stop',
|
|
8
|
-
'marker', 'animate', 'animateTransform', 'animateMotion', 'set', 'filter',
|
|
9
|
-
'feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix',
|
|
10
|
-
'feDiffuseLighting', 'feDisplacementMap', 'feFlood', 'feGaussianBlur', 'feImage',
|
|
11
|
-
'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'feSpecularLighting',
|
|
12
|
-
'feTile', 'feTurbulence',
|
|
13
|
-
]);
|
|
14
|
-
const SVG_NS = 'http://www.w3.org/2000/svg';
|
|
15
|
-
const mountedComponents = new Set();
|
|
16
|
-
function isDomNode(value) {
|
|
17
|
-
if (!value || typeof value !== 'object') return false;
|
|
18
|
-
if (typeof Node !== 'undefined' && value instanceof Node) return true;
|
|
19
|
-
return typeof value.nodeType === 'number' && typeof value.nodeName === 'string';
|
|
20
|
-
}
|
|
21
|
-
function isVNode(value) {
|
|
22
|
-
return !!value && typeof value === 'object' && (value._vnode === true || 'tag' in value);
|
|
23
|
-
}
|
|
24
|
-
function disposeComponent(ctx) {
|
|
25
|
-
if (ctx.disposed) return;
|
|
26
|
-
ctx.disposed = true;
|
|
27
|
-
if (ctx.cleanups) {
|
|
28
|
-
for (const cleanup of ctx.cleanups) {
|
|
29
|
-
try { cleanup(); } catch (e) { console.error('[what] cleanup error:', e); }
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
if (ctx.effects) {
|
|
33
|
-
for (const dispose of ctx.effects) {
|
|
34
|
-
try { dispose(); } catch (e) { }
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
if (ctx.hooks) {
|
|
38
|
-
for (const hook of ctx.hooks) {
|
|
39
|
-
if (hook && typeof hook.cleanup === 'function') {
|
|
40
|
-
try { hook.cleanup(); } catch (e) { console.error('[what] hook cleanup error:', e); }
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
if (ctx._cleanupCallbacks) {
|
|
45
|
-
for (const fn of ctx._cleanupCallbacks) {
|
|
46
|
-
try { fn(); } catch (e) { console.error('[what] onCleanup error:', e); }
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
if (__DEV__ && __devtools?.onComponentUnmount) __devtools.onComponentUnmount(ctx);
|
|
50
|
-
mountedComponents.delete(ctx);
|
|
51
|
-
}
|
|
52
|
-
export function disposeTree(node) {
|
|
53
|
-
if (!node) return;
|
|
54
|
-
if (node._componentCtx) {
|
|
55
|
-
disposeComponent(node._componentCtx);
|
|
56
|
-
}
|
|
57
|
-
if (node._dispose) {
|
|
58
|
-
try { node._dispose(); } catch (e) { }
|
|
59
|
-
}
|
|
60
|
-
if (node._propEffects) {
|
|
61
|
-
for (const key in node._propEffects) {
|
|
62
|
-
try { node._propEffects[key](); } catch (e) { }
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
if (node.childNodes) {
|
|
66
|
-
for (const child of node.childNodes) {
|
|
67
|
-
disposeTree(child);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
export function mount(vnode, container) {
|
|
72
|
-
if (typeof container === 'string') {
|
|
73
|
-
container = document.querySelector(container);
|
|
74
|
-
}
|
|
75
|
-
disposeTree(container);
|
|
76
|
-
container.textContent = '';
|
|
77
|
-
const node = createDOM(vnode, container);
|
|
78
|
-
if (node) container.appendChild(node);
|
|
79
|
-
return () => {
|
|
80
|
-
disposeTree(container);
|
|
81
|
-
container.textContent = '';
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
export function createDOM(vnode, parent, isSvg) {
|
|
85
|
-
if (vnode == null || vnode === false || vnode === true) {
|
|
86
|
-
return document.createComment('');
|
|
87
|
-
}
|
|
88
|
-
if (typeof vnode === 'string' || typeof vnode === 'number') {
|
|
89
|
-
return document.createTextNode(String(vnode));
|
|
90
|
-
}
|
|
91
|
-
if (isDomNode(vnode)) {
|
|
92
|
-
return vnode;
|
|
93
|
-
}
|
|
94
|
-
if (typeof vnode === 'function') {
|
|
95
|
-
const container = document.createDocumentFragment ? document.createElement('span') : document.createElement('span');
|
|
96
|
-
container.style.display = 'contents';
|
|
97
|
-
let currentNodes = [];
|
|
98
|
-
const dispose = effect(() => {
|
|
99
|
-
const val = vnode();
|
|
100
|
-
const vnodes = (val == null || val === false || val === true)
|
|
101
|
-
? []
|
|
102
|
-
: Array.isArray(val) ? val : [val];
|
|
103
|
-
for (const old of currentNodes) {
|
|
104
|
-
disposeTree(old);
|
|
105
|
-
if (old.parentNode === container) container.removeChild(old);
|
|
106
|
-
}
|
|
107
|
-
currentNodes = [];
|
|
108
|
-
for (const v of vnodes) {
|
|
109
|
-
const node = createDOM(v, container, parent?._isSvg);
|
|
110
|
-
if (node) {
|
|
111
|
-
container.appendChild(node);
|
|
112
|
-
currentNodes.push(node);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
container._dispose = dispose;
|
|
117
|
-
return container;
|
|
118
|
-
}
|
|
119
|
-
if (Array.isArray(vnode)) {
|
|
120
|
-
const frag = document.createDocumentFragment();
|
|
121
|
-
for (const child of vnode) {
|
|
122
|
-
const node = createDOM(child, parent, isSvg);
|
|
123
|
-
if (node) frag.appendChild(node);
|
|
124
|
-
}
|
|
125
|
-
return frag;
|
|
126
|
-
}
|
|
127
|
-
if (isVNode(vnode) && typeof vnode.tag === 'function') {
|
|
128
|
-
return createComponent(vnode, parent, isSvg);
|
|
129
|
-
}
|
|
130
|
-
if (isVNode(vnode)) {
|
|
131
|
-
return createElementFromVNode(vnode, parent, isSvg);
|
|
132
|
-
}
|
|
133
|
-
return document.createTextNode(String(vnode));
|
|
134
|
-
}
|
|
135
|
-
const componentStack = [];
|
|
136
|
-
export function getCurrentComponent() {
|
|
137
|
-
return componentStack[componentStack.length - 1];
|
|
138
|
-
}
|
|
139
|
-
_injectGetCurrentComponent(getCurrentComponent);
|
|
140
|
-
_setComponentRef(getCurrentComponent);
|
|
141
|
-
export function getComponentStack() {
|
|
142
|
-
return componentStack;
|
|
143
|
-
}
|
|
144
|
-
function createComponent(vnode, parent, isSvg) {
|
|
145
|
-
let { tag: Component, props, children } = vnode;
|
|
146
|
-
if (typeof Component === 'function' &&
|
|
147
|
-
(Component.prototype?.isReactComponent || Component.prototype?.render)) {
|
|
148
|
-
const ClassComp = Component;
|
|
149
|
-
Component = function ClassComponentBridge(props) {
|
|
150
|
-
const instance = new ClassComp(props);
|
|
151
|
-
return instance.render();
|
|
152
|
-
};
|
|
153
|
-
Component.displayName = ClassComp.displayName || ClassComp.name || 'ClassComponent';
|
|
154
|
-
}
|
|
155
|
-
if (Component === '__errorBoundary' || vnode.tag === '__errorBoundary') {
|
|
156
|
-
return createErrorBoundary(vnode, parent);
|
|
157
|
-
}
|
|
158
|
-
if (Component === '__suspense' || vnode.tag === '__suspense') {
|
|
159
|
-
return createSuspenseBoundary(vnode, parent);
|
|
160
|
-
}
|
|
161
|
-
if (Component === '__portal' || vnode.tag === '__portal') {
|
|
162
|
-
return createPortalDOM(vnode, parent);
|
|
163
|
-
}
|
|
164
|
-
const ctx = {
|
|
165
|
-
hooks: [],
|
|
166
|
-
hookIndex: 0,
|
|
167
|
-
effects: [],
|
|
168
|
-
cleanups: [],
|
|
169
|
-
mounted: false,
|
|
170
|
-
disposed: false,
|
|
171
|
-
Component,
|
|
172
|
-
_parentCtx: componentStack[componentStack.length - 1] || null,
|
|
173
|
-
_errorBoundary: (() => {
|
|
174
|
-
let p = componentStack[componentStack.length - 1];
|
|
175
|
-
while (p) {
|
|
176
|
-
if (p._errorBoundary) return p._errorBoundary;
|
|
177
|
-
p = p._parentCtx;
|
|
178
|
-
}
|
|
179
|
-
return null;
|
|
180
|
-
})()
|
|
181
|
-
};
|
|
182
|
-
const container = document.createElement('span');
|
|
183
|
-
container.style.display = 'contents';
|
|
184
|
-
container._componentCtx = ctx;
|
|
185
|
-
container._isSvg = !!isSvg;
|
|
186
|
-
ctx._wrapper = container;
|
|
187
|
-
mountedComponents.add(ctx);
|
|
188
|
-
if (__DEV__ && __devtools?.onComponentMount) __devtools.onComponentMount(ctx);
|
|
189
|
-
const propsChildren = children.length === 0 ? undefined : children.length === 1 ? children[0] : children;
|
|
190
|
-
const propsSignal = signal({ ...props, children: propsChildren });
|
|
191
|
-
ctx._propsSignal = propsSignal;
|
|
192
|
-
componentStack.push(ctx);
|
|
193
|
-
let result;
|
|
194
|
-
try {
|
|
195
|
-
result = Component(propsSignal());
|
|
196
|
-
} catch (error) {
|
|
197
|
-
componentStack.pop();
|
|
198
|
-
if (!reportError(error, ctx)) {
|
|
199
|
-
console.error('[what] Uncaught error in component:', Component.name || 'Anonymous', error);
|
|
200
|
-
throw error;
|
|
201
|
-
}
|
|
202
|
-
return container;
|
|
203
|
-
}
|
|
204
|
-
componentStack.pop();
|
|
205
|
-
ctx.mounted = true;
|
|
206
|
-
if (ctx._mountCallbacks) {
|
|
207
|
-
queueMicrotask(() => {
|
|
208
|
-
if (ctx.disposed) return;
|
|
209
|
-
for (const fn of ctx._mountCallbacks) {
|
|
210
|
-
try { fn(); } catch (e) { console.error('[what] onMount error:', e); }
|
|
211
|
-
}
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
const vnodes = Array.isArray(result) ? result : [result];
|
|
215
|
-
for (const v of vnodes) {
|
|
216
|
-
const node = createDOM(v, container, isSvg);
|
|
217
|
-
if (node) container.appendChild(node);
|
|
218
|
-
}
|
|
219
|
-
container._vnode = vnode;
|
|
220
|
-
return container;
|
|
221
|
-
}
|
|
222
|
-
function createErrorBoundary(vnode, parent) {
|
|
223
|
-
const { errorState, handleError, fallback, reset } = vnode.props;
|
|
224
|
-
const children = vnode.children;
|
|
225
|
-
const wrapper = document.createElement('span');
|
|
226
|
-
wrapper.style.display = 'contents';
|
|
227
|
-
const boundaryCtx = {
|
|
228
|
-
hooks: [], hookIndex: 0, effects: [], cleanups: [],
|
|
229
|
-
mounted: false, disposed: false,
|
|
230
|
-
_parentCtx: componentStack[componentStack.length - 1] || null,
|
|
231
|
-
_errorBoundary: handleError,
|
|
232
|
-
};
|
|
233
|
-
wrapper._componentCtx = boundaryCtx;
|
|
234
|
-
const dispose = effect(() => {
|
|
235
|
-
const error = errorState();
|
|
236
|
-
componentStack.push(boundaryCtx);
|
|
237
|
-
while (wrapper.firstChild) {
|
|
238
|
-
disposeTree(wrapper.firstChild);
|
|
239
|
-
wrapper.removeChild(wrapper.firstChild);
|
|
240
|
-
}
|
|
241
|
-
let vnodes;
|
|
242
|
-
if (error) {
|
|
243
|
-
vnodes = typeof fallback === 'function' ? [fallback({ error, reset })] : [fallback];
|
|
244
|
-
} else {
|
|
245
|
-
vnodes = children;
|
|
246
|
-
}
|
|
247
|
-
vnodes = Array.isArray(vnodes) ? vnodes : [vnodes];
|
|
248
|
-
for (const v of vnodes) {
|
|
249
|
-
const node = createDOM(v, wrapper);
|
|
250
|
-
if (node) wrapper.appendChild(node);
|
|
251
|
-
}
|
|
252
|
-
componentStack.pop();
|
|
253
|
-
});
|
|
254
|
-
boundaryCtx.effects.push(dispose);
|
|
255
|
-
return wrapper;
|
|
256
|
-
}
|
|
257
|
-
function createSuspenseBoundary(vnode, parent) {
|
|
258
|
-
const { boundary, fallback, loading } = vnode.props;
|
|
259
|
-
const children = vnode.children;
|
|
260
|
-
const wrapper = document.createElement('span');
|
|
261
|
-
wrapper.style.display = 'contents';
|
|
262
|
-
const boundaryCtx = {
|
|
263
|
-
hooks: [], hookIndex: 0, effects: [], cleanups: [],
|
|
264
|
-
mounted: false, disposed: false,
|
|
265
|
-
_parentCtx: componentStack[componentStack.length - 1] || null,
|
|
266
|
-
};
|
|
267
|
-
wrapper._componentCtx = boundaryCtx;
|
|
268
|
-
const dispose = effect(() => {
|
|
269
|
-
const isLoading = loading();
|
|
270
|
-
const vnodes = isLoading ? [fallback] : children;
|
|
271
|
-
const normalized = Array.isArray(vnodes) ? vnodes : [vnodes];
|
|
272
|
-
componentStack.push(boundaryCtx);
|
|
273
|
-
while (wrapper.firstChild) {
|
|
274
|
-
disposeTree(wrapper.firstChild);
|
|
275
|
-
wrapper.removeChild(wrapper.firstChild);
|
|
276
|
-
}
|
|
277
|
-
for (const v of normalized) {
|
|
278
|
-
const node = createDOM(v, wrapper);
|
|
279
|
-
if (node) wrapper.appendChild(node);
|
|
280
|
-
}
|
|
281
|
-
componentStack.pop();
|
|
282
|
-
});
|
|
283
|
-
boundaryCtx.effects.push(dispose);
|
|
284
|
-
return wrapper;
|
|
285
|
-
}
|
|
286
|
-
function createPortalDOM(vnode, parent) {
|
|
287
|
-
const { container } = vnode.props;
|
|
288
|
-
const children = vnode.children;
|
|
289
|
-
if (!container) {
|
|
290
|
-
console.warn('[what] Portal: target container not found');
|
|
291
|
-
return document.createComment('portal:empty');
|
|
292
|
-
}
|
|
293
|
-
const portalCtx = {
|
|
294
|
-
hooks: [], hookIndex: 0, effects: [], cleanups: [],
|
|
295
|
-
mounted: false, disposed: false,
|
|
296
|
-
_parentCtx: componentStack[componentStack.length - 1] || null,
|
|
297
|
-
};
|
|
298
|
-
const placeholder = document.createComment('portal');
|
|
299
|
-
placeholder._componentCtx = portalCtx;
|
|
300
|
-
const portalNodes = [];
|
|
301
|
-
for (const child of children) {
|
|
302
|
-
const node = createDOM(child, container);
|
|
303
|
-
if (node) {
|
|
304
|
-
container.appendChild(node);
|
|
305
|
-
portalNodes.push(node);
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
portalCtx._cleanupCallbacks = [() => {
|
|
309
|
-
for (const node of portalNodes) {
|
|
310
|
-
disposeTree(node);
|
|
311
|
-
if (node.parentNode) node.parentNode.removeChild(node);
|
|
312
|
-
}
|
|
313
|
-
}];
|
|
314
|
-
return placeholder;
|
|
315
|
-
}
|
|
316
|
-
function createElementFromVNode(vnode, parent, isSvg) {
|
|
317
|
-
const { tag, props, children } = vnode;
|
|
318
|
-
const svgContext = isSvg || SVG_ELEMENTS.has(tag);
|
|
319
|
-
const el = svgContext
|
|
320
|
-
? document.createElementNS(SVG_NS, tag)
|
|
321
|
-
: document.createElement(tag);
|
|
322
|
-
if (props) {
|
|
323
|
-
applyProps(el, props, {}, svgContext);
|
|
324
|
-
}
|
|
325
|
-
for (const child of children) {
|
|
326
|
-
const node = createDOM(child, el, svgContext && tag !== 'foreignObject');
|
|
327
|
-
if (node) el.appendChild(node);
|
|
328
|
-
}
|
|
329
|
-
el._vnode = vnode;
|
|
330
|
-
return el;
|
|
331
|
-
}
|
|
332
|
-
function applyProps(el, newProps, oldProps, isSvg) {
|
|
333
|
-
newProps = newProps || {};
|
|
334
|
-
oldProps = oldProps || {};
|
|
335
|
-
for (const key in newProps) {
|
|
336
|
-
if (key === 'key' || key === 'children') continue;
|
|
337
|
-
if (key === 'ref') {
|
|
338
|
-
if (typeof newProps.ref === 'function') newProps.ref(el);
|
|
339
|
-
else if (newProps.ref) newProps.ref.current = el;
|
|
340
|
-
continue;
|
|
341
|
-
}
|
|
342
|
-
setProp(el, key, newProps[key], isSvg);
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
function setProp(el, key, value, isSvg) {
|
|
346
|
-
if (typeof value === 'function' && !(key.startsWith('on') && key.length > 2) && key !== 'ref') {
|
|
347
|
-
if (!el._propEffects) el._propEffects = {};
|
|
348
|
-
if (el._propEffects[key]) {
|
|
349
|
-
try { el._propEffects[key](); } catch (e) { }
|
|
350
|
-
}
|
|
351
|
-
el._propEffects[key] = effect(() => {
|
|
352
|
-
const resolved = value();
|
|
353
|
-
setProp(el, key, resolved, isSvg);
|
|
354
|
-
});
|
|
355
|
-
return;
|
|
356
|
-
}
|
|
357
|
-
if (key.startsWith('on') && key.length > 2) {
|
|
358
|
-
let eventName = key.slice(2);
|
|
359
|
-
let useCapture = false;
|
|
360
|
-
if (eventName.endsWith('Capture')) {
|
|
361
|
-
eventName = eventName.slice(0, -7);
|
|
362
|
-
useCapture = true;
|
|
363
|
-
}
|
|
364
|
-
const event = eventName.toLowerCase();
|
|
365
|
-
const storageKey = useCapture ? event + '_capture' : event;
|
|
366
|
-
const old = el._events?.[storageKey];
|
|
367
|
-
if (old && old._original === value) return;
|
|
368
|
-
if (old) el.removeEventListener(event, old, useCapture);
|
|
369
|
-
if (value == null) return;
|
|
370
|
-
if (!el._events) el._events = {};
|
|
371
|
-
const wrappedHandler = (e) => {
|
|
372
|
-
if (!e.nativeEvent) e.nativeEvent = e;
|
|
373
|
-
return untrack(() => value(e));
|
|
374
|
-
};
|
|
375
|
-
wrappedHandler._original = value;
|
|
376
|
-
el._events[storageKey] = wrappedHandler;
|
|
377
|
-
const eventOpts = value._eventOpts;
|
|
378
|
-
el.addEventListener(event, wrappedHandler, eventOpts || useCapture || undefined);
|
|
379
|
-
return;
|
|
380
|
-
}
|
|
381
|
-
if (key === 'className' || key === 'class') {
|
|
382
|
-
if (isSvg) {
|
|
383
|
-
el.setAttribute('class', value || '');
|
|
384
|
-
} else {
|
|
385
|
-
el.className = value || '';
|
|
386
|
-
}
|
|
387
|
-
return;
|
|
388
|
-
}
|
|
389
|
-
if (key === 'style') {
|
|
390
|
-
if (typeof value === 'string') {
|
|
391
|
-
el.style.cssText = value;
|
|
392
|
-
el._prevStyle = null;
|
|
393
|
-
} else if (typeof value === 'object') {
|
|
394
|
-
const oldStyle = el._prevStyle || {};
|
|
395
|
-
for (const prop in oldStyle) {
|
|
396
|
-
if (!(prop in value)) el.style[prop] = '';
|
|
397
|
-
}
|
|
398
|
-
for (const prop in value) {
|
|
399
|
-
el.style[prop] = value[prop] ?? '';
|
|
400
|
-
}
|
|
401
|
-
el._prevStyle = { ...value };
|
|
402
|
-
}
|
|
403
|
-
return;
|
|
404
|
-
}
|
|
405
|
-
if (key === 'dangerouslySetInnerHTML') {
|
|
406
|
-
el.innerHTML = value?.__html ?? '';
|
|
407
|
-
return;
|
|
408
|
-
}
|
|
409
|
-
if (key === 'innerHTML') {
|
|
410
|
-
if (value && typeof value === 'object' && '__html' in value) {
|
|
411
|
-
el.innerHTML = value.__html ?? '';
|
|
412
|
-
} else {
|
|
413
|
-
el.innerHTML = value ?? '';
|
|
414
|
-
}
|
|
415
|
-
return;
|
|
416
|
-
}
|
|
417
|
-
if (typeof value === 'boolean') {
|
|
418
|
-
if (value) el.setAttribute(key, '');
|
|
419
|
-
else el.removeAttribute(key);
|
|
420
|
-
return;
|
|
421
|
-
}
|
|
422
|
-
if (key.startsWith('data-') || key.startsWith('aria-')) {
|
|
423
|
-
el.setAttribute(key, value);
|
|
424
|
-
return;
|
|
425
|
-
}
|
|
426
|
-
if (isSvg) {
|
|
427
|
-
if (value === false || value == null) {
|
|
428
|
-
el.removeAttribute(key);
|
|
429
|
-
} else {
|
|
430
|
-
el.setAttribute(key, value === true ? '' : String(value));
|
|
431
|
-
}
|
|
432
|
-
return;
|
|
433
|
-
}
|
|
434
|
-
if (key in el) {
|
|
435
|
-
el[key] = value;
|
|
436
|
-
} else {
|
|
437
|
-
el.setAttribute(key, value);
|
|
438
|
-
}
|
|
439
|
-
}
|