Skip to content

Commit ff53bb6

Browse files
authored
Merge branch 'master' into master
2 parents 032b632 + 534eb8f commit ff53bb6

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

src/dom/index.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,13 @@ export function setAccessor(node, name, old, value, isSvg) {
8181
}
8282
else if (name!=='list' && name!=='type' && !isSvg && name in node) {
8383
setProperty(node, name, value==null ? '' : value);
84-
if (value==null || value===false) node.removeAttribute(name);
84+
if ((value==null || value===false) && name!='spellcheck') node.removeAttribute(name);
8585
}
8686
else {
8787
let ns = isSvg && (name !== (name = name.replace(/^xlink:?/, '')));
88+
// spellcheck is treated differently than all other boolean values and
89+
// should not be removed when the value is `false`. See:
90+
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-spellcheck
8891
if (value==null || value===false) {
8992
if (ns) node.removeAttributeNS('http://www.w3.org/1999/xlink', name.toLowerCase());
9093
else node.removeAttribute(name);

src/preact.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ declare global {
690690
sizes?: string;
691691
slot?: string;
692692
span?: number;
693-
spellCheck?: boolean;
693+
spellcheck?: boolean;
694694
src?: string;
695695
srcset?: string;
696696
srcDoc?: string;

test/browser/components.js

+6
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,12 @@ describe('Components', () => {
151151
expect(scratch.innerHTML).to.equal('');
152152
});
153153

154+
// Test for #651
155+
it('should set enumerable boolean attribute', () => {
156+
render(<input spellcheck={false} />, scratch);
157+
expect(scratch.firstChild.spellcheck).to.equal(false);
158+
});
159+
154160
// Test for Issue #73
155161
it('should remove orphaned elements replaced by Components', () => {
156162
class Comp extends Component {

0 commit comments

Comments
 (0)