@@ -86,6 +86,19 @@ function jsxTemplate(templates, ...exprs) {
86
86
const JS_TO_CSS = { } ;
87
87
const CSS_REGEX = / [ A - Z ] / g;
88
88
89
+ /**
90
+ * Unwrap potential signals.
91
+ * @param {* } value
92
+ * @returns {* }
93
+ */
94
+ function normalizeAttrValue ( value ) {
95
+ return value !== null &&
96
+ typeof value === 'object' &&
97
+ typeof value . valueOf === 'function'
98
+ ? value . valueOf ( )
99
+ : value ;
100
+ }
101
+
89
102
/**
90
103
* Serialize an HTML attribute to a string. This function is not
91
104
* expected to be used directly, but rather through a precompile
@@ -100,6 +113,8 @@ function jsxAttr(name, value) {
100
113
if ( typeof result === 'string' ) return result ;
101
114
}
102
115
116
+ value = normalizeAttrValue ( value ) ;
117
+
103
118
if ( name === 'ref' || name === 'key' ) return '' ;
104
119
if ( name === 'style' && typeof value === 'object' ) {
105
120
let str = '' ;
@@ -115,7 +130,7 @@ function jsxAttr(name, value) {
115
130
str = str + name + ':' + val + ';' ;
116
131
}
117
132
}
118
- return name + '="' + str + '"' ;
133
+ return name + '="' + encodeEntities ( str ) + '"' ;
119
134
}
120
135
121
136
if (
@@ -127,7 +142,7 @@ function jsxAttr(name, value) {
127
142
return '' ;
128
143
} else if ( value === true ) return name ;
129
144
130
- return name + '="' + encodeEntities ( value ) + '"' ;
145
+ return name + '="' + encodeEntities ( '' + value ) + '"' ;
131
146
}
132
147
133
148
/**
0 commit comments