Skip to content

Commit 681fc3f

Browse files
fix: escape style object value in precompile transform
1 parent ba198b7 commit 681fc3f

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
@@ -115,7 +115,7 @@ function jsxAttr(name, value) {
115115
str = str + name + ':' + val + ';';
116116
}
117117
}
118-
return name + '="' + str + '"';
118+
return name + '="' + encodeEntities(str) + '"';
119119
}
120120

121121
if (

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

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

123123
it('should escape values', () => {
124124
expect(jsxAttr('foo', "&<'")).to.equal('foo="&amp;&lt;\'"');
125+
expect(jsxAttr('style', { foo: `"&<'"` })).to.equal(
126+
'style="foo:&quot;&amp;&lt;\'&quot;;"'
127+
);
125128
});
126129

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

0 commit comments

Comments
 (0)