@wiajs/core 1.1.33 → 1.2.1
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/core.cjs +1 -1
- package/dist/core.js +1 -1
- package/dist/core.min.js +2 -2
- package/dist/core.mjs +1 -1
- package/dist/jsx-runtime.js +17 -10
- package/package.json +1 -1
package/dist/core.cjs
CHANGED
package/dist/core.js
CHANGED
package/dist/core.min.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* wia core v1.1
|
|
2
|
+
* wia core v1.2.1
|
|
3
3
|
* (c) 2015-2025 Sibyl Yu and contributors
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
/*!
|
|
7
|
-
* wia core v1.1
|
|
7
|
+
* wia core v1.2.1
|
|
8
8
|
* (c) 2015-2025 Sibyl Yu and contributors
|
|
9
9
|
* Released under the MIT License.
|
|
10
10
|
*/
|
package/dist/core.mjs
CHANGED
package/dist/jsx-runtime.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* wia core v1.1
|
|
2
|
+
* wia core v1.2.1
|
|
3
3
|
* (c) 2015-2025 Sibyl Yu and contributors
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -10,6 +10,15 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
10
10
|
var jsxRuntime = {};
|
|
11
11
|
|
|
12
12
|
// runtime: 'automatic', // automatic or classic automatic 使用 JSX 运行时(在React 17 中引入)
|
|
13
|
+
// HTML 属性值转义函数
|
|
14
|
+
function escapeAttrValue(value) {
|
|
15
|
+
return String(value)
|
|
16
|
+
.replace(/&/g, "&")
|
|
17
|
+
.replace(/"/g, """)
|
|
18
|
+
.replace(/</g, "<")
|
|
19
|
+
.replace(/>/g, ">");
|
|
20
|
+
}
|
|
21
|
+
|
|
13
22
|
function jsx(tag, {children, ...props} = {}) {
|
|
14
23
|
let R = '';
|
|
15
24
|
|
|
@@ -20,12 +29,12 @@ function jsx(tag, {children, ...props} = {}) {
|
|
|
20
29
|
|
|
21
30
|
// 特殊处理 className 和 htmlFor
|
|
22
31
|
if (attrs.className) {
|
|
23
|
-
attrsArray.push(`class="${attrs.className}"`);
|
|
32
|
+
attrsArray.push(`class="${escapeAttrValue(attrs.className)}"`);
|
|
24
33
|
delete attrs.className;
|
|
25
34
|
}
|
|
26
35
|
|
|
27
36
|
if (attrs.htmlFor) {
|
|
28
|
-
attrsArray.push(`for="${attrs.htmlFor}"`);
|
|
37
|
+
attrsArray.push(`for="${escapeAttrValue(attrs.htmlFor)}"`);
|
|
29
38
|
delete attrs.htmlFor;
|
|
30
39
|
}
|
|
31
40
|
|
|
@@ -48,7 +57,7 @@ function jsx(tag, {children, ...props} = {}) {
|
|
|
48
57
|
|
|
49
58
|
styleArray.push(`${cssProp}:${cssValue}`);
|
|
50
59
|
}
|
|
51
|
-
attrsArray.push(`style="${styleArray.join(';')}"`);
|
|
60
|
+
attrsArray.push(`style="${escapeAttrValue(styleArray.join(';'))}"`);
|
|
52
61
|
delete attrs.style;
|
|
53
62
|
}
|
|
54
63
|
|
|
@@ -59,13 +68,11 @@ function jsx(tag, {children, ...props} = {}) {
|
|
|
59
68
|
|
|
60
69
|
// 处理布尔属性(如 disabled, checked 等)
|
|
61
70
|
if (typeof value === 'boolean') {
|
|
62
|
-
if (value)
|
|
63
|
-
attrsArray.push(key);
|
|
64
|
-
}
|
|
71
|
+
if (value) attrsArray.push(key);
|
|
65
72
|
}
|
|
66
73
|
// 处理动态值属性
|
|
67
74
|
else if (value != null) {
|
|
68
|
-
attrsArray.push(`${key}="${value}"`);
|
|
75
|
+
attrsArray.push(`${key}="${escapeAttrValue(value)}"`);
|
|
69
76
|
}
|
|
70
77
|
}
|
|
71
78
|
|
|
@@ -85,7 +92,7 @@ function jsx(tag, {children, ...props} = {}) {
|
|
|
85
92
|
// 自闭合标签处理
|
|
86
93
|
const voidElements = ['input', 'img', 'br', 'hr', 'meta', 'link', 'area', 'base', 'col', 'embed', 'param', 'source', 'track', 'wbr', 'path', 'circle', 'polygon', 'line', 'rect', 'ellipse', 'use', 'stop'];
|
|
87
94
|
if (voidElements.includes(tag))
|
|
88
|
-
R = `<${tag}
|
|
95
|
+
R = `<${tag}${attrsString ? ' ' + attrsString : ''} />`;
|
|
89
96
|
else {
|
|
90
97
|
const childrenContent = Array.isArray(children)
|
|
91
98
|
? children
|
|
@@ -103,7 +110,7 @@ function jsx(tag, {children, ...props} = {}) {
|
|
|
103
110
|
? (typeof children === 'boolean' ? '' : children)
|
|
104
111
|
: '';
|
|
105
112
|
|
|
106
|
-
R = `<${tag}
|
|
113
|
+
R = `<${tag}${attrsString ? ' ' + attrsString : ''}>${childrenContent}</${tag}>`;
|
|
107
114
|
}
|
|
108
115
|
}
|
|
109
116
|
|