Skip to content

Commit 2c09969

Browse files
authoredApr 13, 2022
fix(runtime-dom): patch translate as an attr (#5485)
close #5462
1 parent 154233a commit 2c09969

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed
 

‎packages/runtime-dom/__tests__/patchProps.spec.ts

+7
Original file line numberDiff line numberDiff line change
@@ -263,4 +263,11 @@ describe('runtime-dom: props patching', () => {
263263
)
264264
expect(el.value).toBe('baz')
265265
})
266+
267+
test('translate attribute', () => {
268+
const el = document.createElement('div')
269+
patchProp(el, 'translate', null, 'no')
270+
expect(el.translate).toBeFalsy()
271+
expect(el.getAttribute('translate')).toBe('no')
272+
})
266273
})

‎packages/runtime-dom/src/patchProp.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@ function shouldSetAsProp(
7979
return false
8080
}
8181

82-
// spellcheck and draggable are numerated attrs, however their
83-
// corresponding DOM properties are actually booleans - this leads to
84-
// setting it with a string "false" value leading it to be coerced to
85-
// `true`, so we need to always treat them as attributes.
82+
// these are enumerated attrs, however their corresponding DOM properties
83+
// are actually booleans - this leads to setting it with a string "false"
84+
// value leading it to be coerced to `true`, so we need to always treat
85+
// them as attributes.
8686
// Note that `contentEditable` doesn't have this problem: its DOM
8787
// property is also enumerated string values.
88-
if (key === 'spellcheck' || key === 'draggable') {
88+
if (key === 'spellcheck' || key === 'draggable' || key === 'translate') {
8989
return false
9090
}
9191

0 commit comments

Comments
 (0)
Please sign in to comment.