]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(runtime-dom): patch `form` as an attribute (#1788)
authorEduardo San Martin Morote <posva@users.noreply.github.com>
Thu, 6 Aug 2020 13:32:28 +0000 (15:32 +0200)
committerGitHub <noreply@github.com>
Thu, 6 Aug 2020 13:32:28 +0000 (09:32 -0400)
Close #1787

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

index f8c3c06b344d35abb5c7e0330190278733988117..0501e04d01bb03684ad6014fe64dbdc4aed070b3 100644 (file)
@@ -121,4 +121,12 @@ describe('runtime-dom: props patching', () => {
     patchProp(el, 'id', null, '')
     expect(el.hasAttribute('id')).toBe(true)
   })
+
+  test('form attribute', () => {
+    const el = document.createElement('input')
+    patchProp(el, 'form', null, 'foo')
+    // non existant element
+    expect(el.form).toBe(null)
+    expect(el.getAttribute('form')).toBe('foo')
+  })
 })
index a7c27730981e92b5b682fd7ec532e6c8c1e65bf0..91f6ed526dc357c1561390f8c0922b1bc2bc0a23 100644 (file)
@@ -93,6 +93,12 @@ function shouldSetAsProp(
     return false
   }
 
+  // #1787 form as an attribute must be a string, while it accepts an Element as
+  // a prop
+  if (key === 'form' && typeof value === 'string') {
+    return false
+  }
+
   // #1526 <input list> must be set as attribute
   if (key === 'list' && el.tagName === 'INPUT') {
     return false