diff --git a/jsx-runtime/src/index.js b/jsx-runtime/src/index.js index a6a21b8b03..1b20dc2fbf 100644 --- a/jsx-runtime/src/index.js +++ b/jsx-runtime/src/index.js @@ -133,7 +133,7 @@ function jsxAttr(name, value) { str = str + name + ':' + val + suffix; } } - return name + '="' + str + '"'; + return name + '="' + encodeEntities(str) + '"'; } if ( diff --git a/jsx-runtime/test/browser/jsx-runtime.test.js b/jsx-runtime/test/browser/jsx-runtime.test.js index a5ba0daaf0..8a889226ba 100644 --- a/jsx-runtime/test/browser/jsx-runtime.test.js +++ b/jsx-runtime/test/browser/jsx-runtime.test.js @@ -162,6 +162,9 @@ describe('precompiled JSX', () => { it('should escape values', () => { expect(jsxAttr('foo', "&<'")).to.equal('foo="&<\'"'); + expect(jsxAttr('style', { foo: `"&<'"` })).to.equal( + 'style="foo:"&<\'";"' + ); }); it('should call options.attr()', () => {