Skip to content

Commit

Permalink
fix(runtime-dom): patch translate as an attr (#5485)
Browse files Browse the repository at this point in the history
close #5462
  • Loading branch information
zhmushan committed Apr 13, 2022
1 parent 154233a commit 2c09969
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
7 changes: 7 additions & 0 deletions packages/runtime-dom/__tests__/patchProps.spec.ts
Expand Up @@ -263,4 +263,11 @@ describe('runtime-dom: props patching', () => {
)
expect(el.value).toBe('baz')
})

test('translate attribute', () => {
const el = document.createElement('div')
patchProp(el, 'translate', null, 'no')
expect(el.translate).toBeFalsy()
expect(el.getAttribute('translate')).toBe('no')
})
})
10 changes: 5 additions & 5 deletions packages/runtime-dom/src/patchProp.ts
Expand Up @@ -79,13 +79,13 @@ function shouldSetAsProp(
return false
}

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

Expand Down

0 comments on commit 2c09969

Please sign in to comment.