Skip to content

Commit 85e0cab

Browse files
fix: escape style object value in precompile transform
1 parent 5c206b5 commit 85e0cab

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

jsx-runtime/src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ function jsxAttr(name, value) {
133133
str = str + name + ':' + val + suffix;
134134
}
135135
}
136-
return name + '="' + str + '"';
136+
return name + '="' + encodeEntities(str) + '"';
137137
}
138138

139139
if (

jsx-runtime/test/browser/jsx-runtime.test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@ describe('precompiled JSX', () => {
162162

163163
it('should escape values', () => {
164164
expect(jsxAttr('foo', "&<'")).to.equal('foo="&amp;&lt;\'"');
165+
expect(jsxAttr('style', { foo: `"&<'"` })).to.equal(
166+
'style="foo:&quot;&amp;&lt;\'&quot;;"'
167+
);
165168
});
166169

167170
it('should call options.attr()', () => {

0 commit comments

Comments
 (0)