]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(runtime-dom): patch translate as an attr (#5485)
author木杉 <zhmushan@qq.com>
Wed, 13 Apr 2022 09:16:33 +0000 (17:16 +0800)
committerGitHub <noreply@github.com>
Wed, 13 Apr 2022 09:16:33 +0000 (05:16 -0400)
close #5462

packages/runtime-dom/__tests__/patchProps.spec.ts
packages/runtime-dom/src/patchProp.ts

index 07aee676ded1b70fecbd2f2c31364d538341d491..247606950407bdddf3ae14e3bc9c29e04cab881c 100644 (file)
@@ -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')
+  })
 })
index e10d189c581f1e653041ccc65ea8096586609190..6d65a63a88c4d513a3b824196b04e14521e106e0 100644 (file)
@@ -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
   }