@wiajs/core 1.1.32 → 1.1.33

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 CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * wia core v1.1.32
2
+ * wia core v1.1.33
3
3
  * (c) 2015-2025 Sibyl Yu and contributors
4
4
  * Released under the MIT License.
5
5
  */
package/dist/core.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * wia core v1.1.32
2
+ * wia core v1.1.33
3
3
  * (c) 2015-2025 Sibyl Yu and contributors
4
4
  * Released under the MIT License.
5
5
  */
package/dist/core.min.js CHANGED
@@ -1,10 +1,10 @@
1
1
  /*!
2
- * wia core v1.1.32
2
+ * wia core v1.1.33
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.32
7
+ * wia core v1.1.33
8
8
  * (c) 2015-2025 Sibyl Yu and contributors
9
9
  * Released under the MIT License.
10
10
  */
package/dist/core.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * wia core v1.1.32
2
+ * wia core v1.1.33
3
3
  * (c) 2015-2025 Sibyl Yu and contributors
4
4
  * Released under the MIT License.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * wia core v1.1.32
2
+ * wia core v1.1.33
3
3
  * (c) 2015-2025 Sibyl Yu and contributors
4
4
  * Released under the MIT License.
5
5
  */
@@ -29,6 +29,29 @@ function jsx(tag, {children, ...props} = {}) {
29
29
  delete attrs.htmlFor;
30
30
  }
31
31
 
32
+ // 处理 style 对象
33
+ if (attrs.style && typeof attrs.style === 'object') {
34
+ const styleArray = [];
35
+ for (const [key, value] of Object.entries(attrs.style)) {
36
+ if (value == null) continue;
37
+
38
+ // 转换驼峰式属性为CSS属性(backgroundColor -> background-color)
39
+ const cssProp = key.replace(/[A-Z]/g, m => `-${m.toLowerCase()}`);
40
+
41
+ // 处理数值属性(添加px单位)
42
+ let cssValue = value;
43
+ if (typeof value === 'number' &&
44
+ // 这些属性不需要单位
45
+ !['zIndex', 'opacity', 'fontWeight', 'flex', 'order', 'zoom'].includes(key)) {
46
+ cssValue = `${value}px`;
47
+ }
48
+
49
+ styleArray.push(`${cssProp}:${cssValue}`);
50
+ }
51
+ attrsArray.push(`style="${styleArray.join(';')}"`);
52
+ delete attrs.style;
53
+ }
54
+
32
55
  // 处理其他属性
33
56
  for (const [key, value] of Object.entries(attrs)) {
34
57
  // 跳过特殊处理的属性
@@ -66,10 +89,19 @@ function jsx(tag, {children, ...props} = {}) {
66
89
  else {
67
90
  const childrenContent = Array.isArray(children)
68
91
  ? children
69
- .filter(c => c != null)
70
- .map(c => (Array.isArray(c) ? c.join('') : c))
92
+ .filter(c => c != null) // 只过滤 null/undefined
93
+ .map(c => {
94
+ if (Array.isArray(c)) return c.join('');
95
+
96
+ // 特殊处理布尔值(不渲染)
97
+ if (typeof c === 'boolean') return '';
98
+
99
+ return c;
100
+ })
71
101
  .join('')
72
- : children || '';
102
+ : children != null
103
+ ? (typeof children === 'boolean' ? '' : children)
104
+ : '';
73
105
 
74
106
  R = `<${tag} ${attrsString}>${childrenContent}</${tag}>`.trim();
75
107
  }
@@ -81,10 +113,16 @@ function jsx(tag, {children, ...props} = {}) {
81
113
  function Fragment({children} = {}) {
82
114
  const R = Array.isArray(children)
83
115
  ? children
84
- .filter(c => c != null)
85
- .map(c => (Array.isArray(c) ? c.join('') : c))
116
+ .filter(c => c != null) // 只过滤 null/undefined
117
+ .map(c => {
118
+ if (Array.isArray(c)) return c.join('');
119
+ if (typeof c === 'boolean') return '';
120
+ return c;
121
+ })
86
122
  .join('')
87
- : children || '';
123
+ : children != null
124
+ ? (typeof children === 'boolean' ? '' : children)
125
+ : '';
88
126
 
89
127
  return R;
90
128
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wiajs/core",
3
- "version": "1.1.32",
3
+ "version": "1.1.33",
4
4
  "description": "wia app core package",
5
5
  "main": "./dist/core.cjs",
6
6
  "module": "./dist/core.mjs",