@wsxjs/wsx-core 0.0.18 → 0.0.20
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/dist/{chunk-UH5BDYGI.mjs → chunk-7FXISNME.mjs} +181 -2
- package/dist/index.js +181 -2
- package/dist/index.mjs +1 -1
- package/dist/jsx-runtime.js +181 -2
- package/dist/jsx-runtime.mjs +1 -1
- package/dist/jsx.js +181 -2
- package/dist/jsx.mjs +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/jsx-factory.ts +265 -4
- package/dist/chunk-7AUYPTR5.mjs +0 -277
- package/dist/chunk-7WRSZQC3.mjs +0 -256
- package/dist/chunk-CBCT3PYF.mjs +0 -250
- package/dist/chunk-CZII6RG2.mjs +0 -229
- package/dist/chunk-G23NXAPQ.mjs +0 -237
- package/dist/chunk-GOIGP2BR.mjs +0 -271
- package/dist/chunk-H6LR3P4O.mjs +0 -256
- package/dist/chunk-JV57DWHH.mjs +0 -265
|
@@ -125,6 +125,186 @@ function parseHTMLToNodes(html) {
|
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
// src/jsx-factory.ts
|
|
128
|
+
function isStandardHTMLAttribute(key) {
|
|
129
|
+
const standardAttributes = /* @__PURE__ */ new Set([
|
|
130
|
+
// 全局属性
|
|
131
|
+
"id",
|
|
132
|
+
"class",
|
|
133
|
+
"className",
|
|
134
|
+
"style",
|
|
135
|
+
"title",
|
|
136
|
+
"lang",
|
|
137
|
+
"dir",
|
|
138
|
+
"hidden",
|
|
139
|
+
"tabindex",
|
|
140
|
+
"accesskey",
|
|
141
|
+
"contenteditable",
|
|
142
|
+
"draggable",
|
|
143
|
+
"spellcheck",
|
|
144
|
+
"translate",
|
|
145
|
+
"autocapitalize",
|
|
146
|
+
"autocorrect",
|
|
147
|
+
// 表单属性
|
|
148
|
+
"name",
|
|
149
|
+
"value",
|
|
150
|
+
"type",
|
|
151
|
+
"placeholder",
|
|
152
|
+
"required",
|
|
153
|
+
"disabled",
|
|
154
|
+
"readonly",
|
|
155
|
+
"checked",
|
|
156
|
+
"selected",
|
|
157
|
+
"multiple",
|
|
158
|
+
"min",
|
|
159
|
+
"max",
|
|
160
|
+
"step",
|
|
161
|
+
"autocomplete",
|
|
162
|
+
"autofocus",
|
|
163
|
+
"form",
|
|
164
|
+
"formaction",
|
|
165
|
+
"formenctype",
|
|
166
|
+
"formmethod",
|
|
167
|
+
"formnovalidate",
|
|
168
|
+
"formtarget",
|
|
169
|
+
// 链接属性
|
|
170
|
+
"href",
|
|
171
|
+
"target",
|
|
172
|
+
"rel",
|
|
173
|
+
"download",
|
|
174
|
+
"hreflang",
|
|
175
|
+
"ping",
|
|
176
|
+
// 媒体属性
|
|
177
|
+
"src",
|
|
178
|
+
"alt",
|
|
179
|
+
"width",
|
|
180
|
+
"height",
|
|
181
|
+
"poster",
|
|
182
|
+
"preload",
|
|
183
|
+
"controls",
|
|
184
|
+
"autoplay",
|
|
185
|
+
"loop",
|
|
186
|
+
"muted",
|
|
187
|
+
"playsinline",
|
|
188
|
+
"crossorigin",
|
|
189
|
+
// ARIA 属性(部分常见)
|
|
190
|
+
"role"
|
|
191
|
+
]);
|
|
192
|
+
const lowerKey = key.toLowerCase();
|
|
193
|
+
if (standardAttributes.has(lowerKey)) {
|
|
194
|
+
return true;
|
|
195
|
+
}
|
|
196
|
+
if (lowerKey.startsWith("data-")) {
|
|
197
|
+
return true;
|
|
198
|
+
}
|
|
199
|
+
if (lowerKey.startsWith("aria-")) {
|
|
200
|
+
return true;
|
|
201
|
+
}
|
|
202
|
+
if (key.startsWith("xml:") || key.startsWith("xlink:")) {
|
|
203
|
+
return true;
|
|
204
|
+
}
|
|
205
|
+
return false;
|
|
206
|
+
}
|
|
207
|
+
function isSpecialProperty(key, value) {
|
|
208
|
+
return key === "ref" || key === "className" || key === "class" || key === "style" || key.startsWith("on") && typeof value === "function" || typeof value === "boolean" || key === "value";
|
|
209
|
+
}
|
|
210
|
+
function setSmartProperty(element, key, value, isSVG = false) {
|
|
211
|
+
if (isSpecialProperty(key, value)) {
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
if (isStandardHTMLAttribute(key)) {
|
|
215
|
+
const attributeName = isSVG ? getSVGAttributeName(key) : key;
|
|
216
|
+
if (typeof value === "object" && value !== null) {
|
|
217
|
+
try {
|
|
218
|
+
const serialized = JSON.stringify(value);
|
|
219
|
+
if (serialized.length > 1024 * 1024) {
|
|
220
|
+
console.warn(
|
|
221
|
+
`[WSX] Attribute "${key}" value too large, consider using a non-standard property name instead`
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
element.setAttribute(attributeName, serialized);
|
|
225
|
+
} catch (error) {
|
|
226
|
+
console.warn(`[WSX] Cannot serialize attribute "${key}":`, error);
|
|
227
|
+
}
|
|
228
|
+
} else {
|
|
229
|
+
element.setAttribute(attributeName, String(value));
|
|
230
|
+
}
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
if (element instanceof SVGElement) {
|
|
234
|
+
const attributeName = getSVGAttributeName(key);
|
|
235
|
+
if (typeof value === "object" && value !== null) {
|
|
236
|
+
try {
|
|
237
|
+
const serialized = JSON.stringify(value);
|
|
238
|
+
element.setAttribute(attributeName, serialized);
|
|
239
|
+
} catch (error) {
|
|
240
|
+
console.warn(`[WSX] Cannot serialize SVG attribute "${key}":`, error);
|
|
241
|
+
}
|
|
242
|
+
} else {
|
|
243
|
+
element.setAttribute(attributeName, String(value));
|
|
244
|
+
}
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
const hasProperty = key in element || Object.prototype.hasOwnProperty.call(element, key);
|
|
248
|
+
if (hasProperty) {
|
|
249
|
+
let isReadOnly = false;
|
|
250
|
+
try {
|
|
251
|
+
const descriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(element), key);
|
|
252
|
+
if (descriptor) {
|
|
253
|
+
isReadOnly = descriptor.get !== void 0 && descriptor.set === void 0 || descriptor.writable === false && descriptor.set === void 0;
|
|
254
|
+
}
|
|
255
|
+
} catch {
|
|
256
|
+
}
|
|
257
|
+
if (isReadOnly) {
|
|
258
|
+
const attributeName = isSVG ? getSVGAttributeName(key) : key;
|
|
259
|
+
if (typeof value === "object" && value !== null) {
|
|
260
|
+
try {
|
|
261
|
+
const serialized = JSON.stringify(value);
|
|
262
|
+
element.setAttribute(attributeName, serialized);
|
|
263
|
+
} catch (error) {
|
|
264
|
+
console.warn(`[WSX] Cannot serialize readonly property "${key}":`, error);
|
|
265
|
+
}
|
|
266
|
+
} else {
|
|
267
|
+
element.setAttribute(attributeName, String(value));
|
|
268
|
+
}
|
|
269
|
+
} else {
|
|
270
|
+
try {
|
|
271
|
+
element[key] = value;
|
|
272
|
+
} catch {
|
|
273
|
+
const attributeName = isSVG ? getSVGAttributeName(key) : key;
|
|
274
|
+
if (typeof value === "object" && value !== null) {
|
|
275
|
+
try {
|
|
276
|
+
const serialized = JSON.stringify(value);
|
|
277
|
+
element.setAttribute(attributeName, serialized);
|
|
278
|
+
} catch (error) {
|
|
279
|
+
console.warn(
|
|
280
|
+
`[WSX] Cannot serialize property "${key}" for attribute:`,
|
|
281
|
+
error
|
|
282
|
+
);
|
|
283
|
+
}
|
|
284
|
+
} else {
|
|
285
|
+
element.setAttribute(attributeName, String(value));
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
} else {
|
|
290
|
+
const attributeName = isSVG ? getSVGAttributeName(key) : key;
|
|
291
|
+
if (typeof value === "object" && value !== null) {
|
|
292
|
+
try {
|
|
293
|
+
const serialized = JSON.stringify(value);
|
|
294
|
+
if (serialized.length > 1024 * 1024) {
|
|
295
|
+
console.warn(
|
|
296
|
+
`[WSX] Property "${key}" value too large for attribute, consider using a JavaScript property instead`
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
element.setAttribute(attributeName, serialized);
|
|
300
|
+
} catch (error) {
|
|
301
|
+
console.warn(`[WSX] Cannot serialize property "${key}" for attribute:`, error);
|
|
302
|
+
}
|
|
303
|
+
} else {
|
|
304
|
+
element.setAttribute(attributeName, String(value));
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
128
308
|
function h(tag, props = {}, ...children) {
|
|
129
309
|
if (typeof tag === "function") {
|
|
130
310
|
return tag(props, children);
|
|
@@ -161,8 +341,7 @@ function h(tag, props = {}, ...children) {
|
|
|
161
341
|
element.setAttribute(attributeName, String(value));
|
|
162
342
|
}
|
|
163
343
|
} else {
|
|
164
|
-
|
|
165
|
-
element.setAttribute(attributeName, String(value));
|
|
344
|
+
setSmartProperty(element, key, value, isSVG);
|
|
166
345
|
}
|
|
167
346
|
});
|
|
168
347
|
}
|
package/dist/index.js
CHANGED
|
@@ -164,6 +164,186 @@ function parseHTMLToNodes(html) {
|
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
// src/jsx-factory.ts
|
|
167
|
+
function isStandardHTMLAttribute(key) {
|
|
168
|
+
const standardAttributes = /* @__PURE__ */ new Set([
|
|
169
|
+
// 全局属性
|
|
170
|
+
"id",
|
|
171
|
+
"class",
|
|
172
|
+
"className",
|
|
173
|
+
"style",
|
|
174
|
+
"title",
|
|
175
|
+
"lang",
|
|
176
|
+
"dir",
|
|
177
|
+
"hidden",
|
|
178
|
+
"tabindex",
|
|
179
|
+
"accesskey",
|
|
180
|
+
"contenteditable",
|
|
181
|
+
"draggable",
|
|
182
|
+
"spellcheck",
|
|
183
|
+
"translate",
|
|
184
|
+
"autocapitalize",
|
|
185
|
+
"autocorrect",
|
|
186
|
+
// 表单属性
|
|
187
|
+
"name",
|
|
188
|
+
"value",
|
|
189
|
+
"type",
|
|
190
|
+
"placeholder",
|
|
191
|
+
"required",
|
|
192
|
+
"disabled",
|
|
193
|
+
"readonly",
|
|
194
|
+
"checked",
|
|
195
|
+
"selected",
|
|
196
|
+
"multiple",
|
|
197
|
+
"min",
|
|
198
|
+
"max",
|
|
199
|
+
"step",
|
|
200
|
+
"autocomplete",
|
|
201
|
+
"autofocus",
|
|
202
|
+
"form",
|
|
203
|
+
"formaction",
|
|
204
|
+
"formenctype",
|
|
205
|
+
"formmethod",
|
|
206
|
+
"formnovalidate",
|
|
207
|
+
"formtarget",
|
|
208
|
+
// 链接属性
|
|
209
|
+
"href",
|
|
210
|
+
"target",
|
|
211
|
+
"rel",
|
|
212
|
+
"download",
|
|
213
|
+
"hreflang",
|
|
214
|
+
"ping",
|
|
215
|
+
// 媒体属性
|
|
216
|
+
"src",
|
|
217
|
+
"alt",
|
|
218
|
+
"width",
|
|
219
|
+
"height",
|
|
220
|
+
"poster",
|
|
221
|
+
"preload",
|
|
222
|
+
"controls",
|
|
223
|
+
"autoplay",
|
|
224
|
+
"loop",
|
|
225
|
+
"muted",
|
|
226
|
+
"playsinline",
|
|
227
|
+
"crossorigin",
|
|
228
|
+
// ARIA 属性(部分常见)
|
|
229
|
+
"role"
|
|
230
|
+
]);
|
|
231
|
+
const lowerKey = key.toLowerCase();
|
|
232
|
+
if (standardAttributes.has(lowerKey)) {
|
|
233
|
+
return true;
|
|
234
|
+
}
|
|
235
|
+
if (lowerKey.startsWith("data-")) {
|
|
236
|
+
return true;
|
|
237
|
+
}
|
|
238
|
+
if (lowerKey.startsWith("aria-")) {
|
|
239
|
+
return true;
|
|
240
|
+
}
|
|
241
|
+
if (key.startsWith("xml:") || key.startsWith("xlink:")) {
|
|
242
|
+
return true;
|
|
243
|
+
}
|
|
244
|
+
return false;
|
|
245
|
+
}
|
|
246
|
+
function isSpecialProperty(key, value) {
|
|
247
|
+
return key === "ref" || key === "className" || key === "class" || key === "style" || key.startsWith("on") && typeof value === "function" || typeof value === "boolean" || key === "value";
|
|
248
|
+
}
|
|
249
|
+
function setSmartProperty(element, key, value, isSVG = false) {
|
|
250
|
+
if (isSpecialProperty(key, value)) {
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
if (isStandardHTMLAttribute(key)) {
|
|
254
|
+
const attributeName = isSVG ? getSVGAttributeName(key) : key;
|
|
255
|
+
if (typeof value === "object" && value !== null) {
|
|
256
|
+
try {
|
|
257
|
+
const serialized = JSON.stringify(value);
|
|
258
|
+
if (serialized.length > 1024 * 1024) {
|
|
259
|
+
console.warn(
|
|
260
|
+
`[WSX] Attribute "${key}" value too large, consider using a non-standard property name instead`
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
element.setAttribute(attributeName, serialized);
|
|
264
|
+
} catch (error) {
|
|
265
|
+
console.warn(`[WSX] Cannot serialize attribute "${key}":`, error);
|
|
266
|
+
}
|
|
267
|
+
} else {
|
|
268
|
+
element.setAttribute(attributeName, String(value));
|
|
269
|
+
}
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
if (element instanceof SVGElement) {
|
|
273
|
+
const attributeName = getSVGAttributeName(key);
|
|
274
|
+
if (typeof value === "object" && value !== null) {
|
|
275
|
+
try {
|
|
276
|
+
const serialized = JSON.stringify(value);
|
|
277
|
+
element.setAttribute(attributeName, serialized);
|
|
278
|
+
} catch (error) {
|
|
279
|
+
console.warn(`[WSX] Cannot serialize SVG attribute "${key}":`, error);
|
|
280
|
+
}
|
|
281
|
+
} else {
|
|
282
|
+
element.setAttribute(attributeName, String(value));
|
|
283
|
+
}
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
const hasProperty = key in element || Object.prototype.hasOwnProperty.call(element, key);
|
|
287
|
+
if (hasProperty) {
|
|
288
|
+
let isReadOnly = false;
|
|
289
|
+
try {
|
|
290
|
+
const descriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(element), key);
|
|
291
|
+
if (descriptor) {
|
|
292
|
+
isReadOnly = descriptor.get !== void 0 && descriptor.set === void 0 || descriptor.writable === false && descriptor.set === void 0;
|
|
293
|
+
}
|
|
294
|
+
} catch {
|
|
295
|
+
}
|
|
296
|
+
if (isReadOnly) {
|
|
297
|
+
const attributeName = isSVG ? getSVGAttributeName(key) : key;
|
|
298
|
+
if (typeof value === "object" && value !== null) {
|
|
299
|
+
try {
|
|
300
|
+
const serialized = JSON.stringify(value);
|
|
301
|
+
element.setAttribute(attributeName, serialized);
|
|
302
|
+
} catch (error) {
|
|
303
|
+
console.warn(`[WSX] Cannot serialize readonly property "${key}":`, error);
|
|
304
|
+
}
|
|
305
|
+
} else {
|
|
306
|
+
element.setAttribute(attributeName, String(value));
|
|
307
|
+
}
|
|
308
|
+
} else {
|
|
309
|
+
try {
|
|
310
|
+
element[key] = value;
|
|
311
|
+
} catch {
|
|
312
|
+
const attributeName = isSVG ? getSVGAttributeName(key) : key;
|
|
313
|
+
if (typeof value === "object" && value !== null) {
|
|
314
|
+
try {
|
|
315
|
+
const serialized = JSON.stringify(value);
|
|
316
|
+
element.setAttribute(attributeName, serialized);
|
|
317
|
+
} catch (error) {
|
|
318
|
+
console.warn(
|
|
319
|
+
`[WSX] Cannot serialize property "${key}" for attribute:`,
|
|
320
|
+
error
|
|
321
|
+
);
|
|
322
|
+
}
|
|
323
|
+
} else {
|
|
324
|
+
element.setAttribute(attributeName, String(value));
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
} else {
|
|
329
|
+
const attributeName = isSVG ? getSVGAttributeName(key) : key;
|
|
330
|
+
if (typeof value === "object" && value !== null) {
|
|
331
|
+
try {
|
|
332
|
+
const serialized = JSON.stringify(value);
|
|
333
|
+
if (serialized.length > 1024 * 1024) {
|
|
334
|
+
console.warn(
|
|
335
|
+
`[WSX] Property "${key}" value too large for attribute, consider using a JavaScript property instead`
|
|
336
|
+
);
|
|
337
|
+
}
|
|
338
|
+
element.setAttribute(attributeName, serialized);
|
|
339
|
+
} catch (error) {
|
|
340
|
+
console.warn(`[WSX] Cannot serialize property "${key}" for attribute:`, error);
|
|
341
|
+
}
|
|
342
|
+
} else {
|
|
343
|
+
element.setAttribute(attributeName, String(value));
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
}
|
|
167
347
|
function h(tag, props = {}, ...children) {
|
|
168
348
|
if (typeof tag === "function") {
|
|
169
349
|
return tag(props, children);
|
|
@@ -200,8 +380,7 @@ function h(tag, props = {}, ...children) {
|
|
|
200
380
|
element.setAttribute(attributeName, String(value));
|
|
201
381
|
}
|
|
202
382
|
} else {
|
|
203
|
-
|
|
204
|
-
element.setAttribute(attributeName, String(value));
|
|
383
|
+
setSmartProperty(element, key, value, isSVG);
|
|
205
384
|
}
|
|
206
385
|
});
|
|
207
386
|
}
|
package/dist/index.mjs
CHANGED
package/dist/jsx-runtime.js
CHANGED
|
@@ -153,6 +153,186 @@ function parseHTMLToNodes(html) {
|
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
// src/jsx-factory.ts
|
|
156
|
+
function isStandardHTMLAttribute(key) {
|
|
157
|
+
const standardAttributes = /* @__PURE__ */ new Set([
|
|
158
|
+
// 全局属性
|
|
159
|
+
"id",
|
|
160
|
+
"class",
|
|
161
|
+
"className",
|
|
162
|
+
"style",
|
|
163
|
+
"title",
|
|
164
|
+
"lang",
|
|
165
|
+
"dir",
|
|
166
|
+
"hidden",
|
|
167
|
+
"tabindex",
|
|
168
|
+
"accesskey",
|
|
169
|
+
"contenteditable",
|
|
170
|
+
"draggable",
|
|
171
|
+
"spellcheck",
|
|
172
|
+
"translate",
|
|
173
|
+
"autocapitalize",
|
|
174
|
+
"autocorrect",
|
|
175
|
+
// 表单属性
|
|
176
|
+
"name",
|
|
177
|
+
"value",
|
|
178
|
+
"type",
|
|
179
|
+
"placeholder",
|
|
180
|
+
"required",
|
|
181
|
+
"disabled",
|
|
182
|
+
"readonly",
|
|
183
|
+
"checked",
|
|
184
|
+
"selected",
|
|
185
|
+
"multiple",
|
|
186
|
+
"min",
|
|
187
|
+
"max",
|
|
188
|
+
"step",
|
|
189
|
+
"autocomplete",
|
|
190
|
+
"autofocus",
|
|
191
|
+
"form",
|
|
192
|
+
"formaction",
|
|
193
|
+
"formenctype",
|
|
194
|
+
"formmethod",
|
|
195
|
+
"formnovalidate",
|
|
196
|
+
"formtarget",
|
|
197
|
+
// 链接属性
|
|
198
|
+
"href",
|
|
199
|
+
"target",
|
|
200
|
+
"rel",
|
|
201
|
+
"download",
|
|
202
|
+
"hreflang",
|
|
203
|
+
"ping",
|
|
204
|
+
// 媒体属性
|
|
205
|
+
"src",
|
|
206
|
+
"alt",
|
|
207
|
+
"width",
|
|
208
|
+
"height",
|
|
209
|
+
"poster",
|
|
210
|
+
"preload",
|
|
211
|
+
"controls",
|
|
212
|
+
"autoplay",
|
|
213
|
+
"loop",
|
|
214
|
+
"muted",
|
|
215
|
+
"playsinline",
|
|
216
|
+
"crossorigin",
|
|
217
|
+
// ARIA 属性(部分常见)
|
|
218
|
+
"role"
|
|
219
|
+
]);
|
|
220
|
+
const lowerKey = key.toLowerCase();
|
|
221
|
+
if (standardAttributes.has(lowerKey)) {
|
|
222
|
+
return true;
|
|
223
|
+
}
|
|
224
|
+
if (lowerKey.startsWith("data-")) {
|
|
225
|
+
return true;
|
|
226
|
+
}
|
|
227
|
+
if (lowerKey.startsWith("aria-")) {
|
|
228
|
+
return true;
|
|
229
|
+
}
|
|
230
|
+
if (key.startsWith("xml:") || key.startsWith("xlink:")) {
|
|
231
|
+
return true;
|
|
232
|
+
}
|
|
233
|
+
return false;
|
|
234
|
+
}
|
|
235
|
+
function isSpecialProperty(key, value) {
|
|
236
|
+
return key === "ref" || key === "className" || key === "class" || key === "style" || key.startsWith("on") && typeof value === "function" || typeof value === "boolean" || key === "value";
|
|
237
|
+
}
|
|
238
|
+
function setSmartProperty(element, key, value, isSVG = false) {
|
|
239
|
+
if (isSpecialProperty(key, value)) {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
if (isStandardHTMLAttribute(key)) {
|
|
243
|
+
const attributeName = isSVG ? getSVGAttributeName(key) : key;
|
|
244
|
+
if (typeof value === "object" && value !== null) {
|
|
245
|
+
try {
|
|
246
|
+
const serialized = JSON.stringify(value);
|
|
247
|
+
if (serialized.length > 1024 * 1024) {
|
|
248
|
+
console.warn(
|
|
249
|
+
`[WSX] Attribute "${key}" value too large, consider using a non-standard property name instead`
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
element.setAttribute(attributeName, serialized);
|
|
253
|
+
} catch (error) {
|
|
254
|
+
console.warn(`[WSX] Cannot serialize attribute "${key}":`, error);
|
|
255
|
+
}
|
|
256
|
+
} else {
|
|
257
|
+
element.setAttribute(attributeName, String(value));
|
|
258
|
+
}
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
if (element instanceof SVGElement) {
|
|
262
|
+
const attributeName = getSVGAttributeName(key);
|
|
263
|
+
if (typeof value === "object" && value !== null) {
|
|
264
|
+
try {
|
|
265
|
+
const serialized = JSON.stringify(value);
|
|
266
|
+
element.setAttribute(attributeName, serialized);
|
|
267
|
+
} catch (error) {
|
|
268
|
+
console.warn(`[WSX] Cannot serialize SVG attribute "${key}":`, error);
|
|
269
|
+
}
|
|
270
|
+
} else {
|
|
271
|
+
element.setAttribute(attributeName, String(value));
|
|
272
|
+
}
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
const hasProperty = key in element || Object.prototype.hasOwnProperty.call(element, key);
|
|
276
|
+
if (hasProperty) {
|
|
277
|
+
let isReadOnly = false;
|
|
278
|
+
try {
|
|
279
|
+
const descriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(element), key);
|
|
280
|
+
if (descriptor) {
|
|
281
|
+
isReadOnly = descriptor.get !== void 0 && descriptor.set === void 0 || descriptor.writable === false && descriptor.set === void 0;
|
|
282
|
+
}
|
|
283
|
+
} catch {
|
|
284
|
+
}
|
|
285
|
+
if (isReadOnly) {
|
|
286
|
+
const attributeName = isSVG ? getSVGAttributeName(key) : key;
|
|
287
|
+
if (typeof value === "object" && value !== null) {
|
|
288
|
+
try {
|
|
289
|
+
const serialized = JSON.stringify(value);
|
|
290
|
+
element.setAttribute(attributeName, serialized);
|
|
291
|
+
} catch (error) {
|
|
292
|
+
console.warn(`[WSX] Cannot serialize readonly property "${key}":`, error);
|
|
293
|
+
}
|
|
294
|
+
} else {
|
|
295
|
+
element.setAttribute(attributeName, String(value));
|
|
296
|
+
}
|
|
297
|
+
} else {
|
|
298
|
+
try {
|
|
299
|
+
element[key] = value;
|
|
300
|
+
} catch {
|
|
301
|
+
const attributeName = isSVG ? getSVGAttributeName(key) : key;
|
|
302
|
+
if (typeof value === "object" && value !== null) {
|
|
303
|
+
try {
|
|
304
|
+
const serialized = JSON.stringify(value);
|
|
305
|
+
element.setAttribute(attributeName, serialized);
|
|
306
|
+
} catch (error) {
|
|
307
|
+
console.warn(
|
|
308
|
+
`[WSX] Cannot serialize property "${key}" for attribute:`,
|
|
309
|
+
error
|
|
310
|
+
);
|
|
311
|
+
}
|
|
312
|
+
} else {
|
|
313
|
+
element.setAttribute(attributeName, String(value));
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
} else {
|
|
318
|
+
const attributeName = isSVG ? getSVGAttributeName(key) : key;
|
|
319
|
+
if (typeof value === "object" && value !== null) {
|
|
320
|
+
try {
|
|
321
|
+
const serialized = JSON.stringify(value);
|
|
322
|
+
if (serialized.length > 1024 * 1024) {
|
|
323
|
+
console.warn(
|
|
324
|
+
`[WSX] Property "${key}" value too large for attribute, consider using a JavaScript property instead`
|
|
325
|
+
);
|
|
326
|
+
}
|
|
327
|
+
element.setAttribute(attributeName, serialized);
|
|
328
|
+
} catch (error) {
|
|
329
|
+
console.warn(`[WSX] Cannot serialize property "${key}" for attribute:`, error);
|
|
330
|
+
}
|
|
331
|
+
} else {
|
|
332
|
+
element.setAttribute(attributeName, String(value));
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
156
336
|
function h(tag, props = {}, ...children) {
|
|
157
337
|
if (typeof tag === "function") {
|
|
158
338
|
return tag(props, children);
|
|
@@ -189,8 +369,7 @@ function h(tag, props = {}, ...children) {
|
|
|
189
369
|
element.setAttribute(attributeName, String(value));
|
|
190
370
|
}
|
|
191
371
|
} else {
|
|
192
|
-
|
|
193
|
-
element.setAttribute(attributeName, String(value));
|
|
372
|
+
setSmartProperty(element, key, value, isSVG);
|
|
194
373
|
}
|
|
195
374
|
});
|
|
196
375
|
}
|