Skip to content

Commit 8d41b25

Browse files
committed
fix: Support spellcheck and remove support for spellCheck
1 parent e7ec96b commit 8d41b25

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

src/index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
UNSAFE_NAME,
55
NAMESPACE_REPLACE_REGEX,
66
HTML_LOWER_CASE,
7+
HTML_ENUMERATED,
78
SVG_CAMEL_CASE,
89
createComponent
910
} from './lib/util.js';
@@ -623,7 +624,10 @@ function _renderToString(
623624
name = name.replace(NAMESPACE_REPLACE_REGEX, '$1:$2').toLowerCase();
624625
} else if (UNSAFE_NAME.test(name)) {
625626
continue;
626-
} else if ((name[4] === '-' || name === 'draggable') && v != null) {
627+
} else if (
628+
(name[4] === '-' || HTML_ENUMERATED.test(name)) &&
629+
v != null
630+
) {
627631
// serialize boolean aria-xyz or draggable attribute values as strings
628632
// `draggable` is an enumerated attribute and not Boolean. A value of `true` or `false` is mandatory
629633
// https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/draggable
@@ -637,9 +641,6 @@ function _renderToString(
637641
}
638642
} else if (HTML_LOWER_CASE.test(name)) {
639643
name = name.toLowerCase();
640-
if (name === 'spellcheck') {
641-
v = '' + v;
642-
}
643644
}
644645
}
645646
}

src/lib/util.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
export const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/;
22
export const UNSAFE_NAME = /[\s\n\\/='"\0<>]/;
33
export const NAMESPACE_REPLACE_REGEX = /^(xlink|xmlns|xml)([A-Z])/;
4-
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|spel|text[^L]|transform|underline|unicode|units|^v[^i]|^w|^xH/;
4+
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|src[A-Z]|tabI|useM|item[A-Z]/;
5+
export const HTML_ENUMERATED = /^dra|spel/;
6+
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/;
67

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

test/render.test.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,11 @@ 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} />);
157+
it('should support spellcheck', () => {
158+
let rendered = render(<div spellcheck={false} />);
159159
expect(rendered).to.equal(`<div spellcheck="false"></div>`);
160160

161-
rendered = render(<div spellCheck />);
161+
rendered = render(<div spellcheck />);
162162
expect(rendered).to.equal(`<div spellcheck="true"></div>`);
163163
});
164164

test/utils.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,6 @@ export const htmlAttributes = {
400400
slot: 'slot',
401401
span: 'span',
402402
spellcheck: 'spellcheck',
403-
spellCheck: 'spellcheck',
404403
src: 'src',
405404
srcset: 'srcset',
406405
srcDoc: 'srcdoc',

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy