Skip to content

Commit ccce46e

Browse files
committed
fix(vdom): boolean properties in native elements
fixes #1899
1 parent 9136f3a commit ccce46e

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/runtime/vdom/set-accessor.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ export const setAccessor = (elm: HTMLElement, memberName: string, oldValue: any,
100100
let n = newValue == null ? '' : newValue;
101101

102102
// Workaround for Safari, moving the <input> caret when re-assigning the same valued
103-
if (oldValue == null || (elm as any)[memberName] !== (n = String(n))) {
103+
// tslint:disable-next-line: triple-equals
104+
if (oldValue == null || (elm as any)[memberName] != n) {
104105
(elm as any)[memberName] = n;
105106
}
106107
} else {

src/runtime/vdom/test/set-accessor.spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,15 @@ describe('setAccessor for inputs', () => {
321321
testStraightForwardAttribute('spellCheck', undefined, undefined);
322322
testStraightForwardAttribute('spellCheck', null, undefined);
323323
});
324+
325+
it ('checked', () => {
326+
const inputElm = document.createElement('input');
327+
setAccessor(inputElm, 'checked', false, true, false, 0);
328+
expect(inputElm.checked).toEqual(true);
329+
330+
setAccessor(inputElm, 'checked', true, false, false, 0);
331+
expect(inputElm.checked).toEqual(false);
332+
});
324333
});
325334

326335
describe('should update when prop is defined', () => {

0 commit comments

Comments
 (0)