Skip to content

Commit 1754f99

Browse files
Merge pull request #388 from preactjs/spellcheck
fix: wrong spellcheck attribute value
2 parents b40944a + 4621fa3 commit 1754f99

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

.changeset/young-avocados-float.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'preact-render-to-string': patch
3+
---
4+
5+
Fix `spellCheck={false}` not rendering as `spellcheck="false"`

src/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,9 @@ function _renderToString(
635635
}
636636
} else if (HTML_LOWER_CASE.test(name)) {
637637
name = name.toLowerCase();
638+
if (name === 'spellcheck') {
639+
v = '' + v;
640+
}
638641
}
639642
}
640643
}

src/lib/util.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|link|meta|
22
export const UNSAFE_NAME = /[\s\n\\/='"\0<>]/;
33
export const NAMESPACE_REPLACE_REGEX = /^(xlink|xmlns|xml)([A-Z])/;
44
export const HTML_LOWER_CASE = /^accessK|^auto[A-Z]|^cell|^ch|^col|cont|cross|dateT|encT|form[A-Z]|frame|hrefL|inputM|maxL|minL|noV|playsI|popoverT|readO|rowS|spellC|src[A-Z]|tabI|useM|item[A-Z]/;
5-
export const SVG_CAMEL_CASE = /^ac|^ali|arabic|basel|cap|clipPath$|clipRule$|color|dominant|enable|fill|flood|font|glyph[^R]|horiz|image|letter|lighting|marker[^WUH]|overline|panose|pointe|paint|rendering|shape|stop|strikethrough|stroke|text[^L]|transform|underline|unicode|units|^v[^i]|^w|^xH/;
5+
export const SVG_CAMEL_CASE = /^ac|^ali|arabic|basel|cap|clipPath$|clipRule$|color|dominant|enable|fill|flood|font|glyph[^R]|horiz|image|letter|lighting|marker[^WUH]|overline|panose|pointe|paint|rendering|shape|stop|strikethrough|stroke|spel|text[^L]|transform|underline|unicode|units|^v[^i]|^w|^xH/;
66

77
// DOM properties that should NOT have "px" added when numeric
88
const ENCODED_ENTITIES = /["&<]/;

test/render.test.jsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,14 @@ describe('render', () => {
154154
expect(rendered).to.equal(`<div data-checked="false"></div>`);
155155
});
156156

157+
it('should support spellCheck', () => {
158+
let rendered = render(<div spellCheck={false} />);
159+
expect(rendered).to.equal(`<div spellcheck="false"></div>`);
160+
161+
rendered = render(<div spellCheck />);
162+
expect(rendered).to.equal(`<div spellcheck="true"></div>`);
163+
});
164+
157165
describe('attribute name sanitization', () => {
158166
it('should omit attributes with invalid names', () => {
159167
let rendered = render(

0 commit comments

Comments
 (0)