Skip to content

Commit 180310c

Browse files
committed
refactor(runtime-dom): avoid form attribtue tag check
the tag check while technically stricter, is not really necessary and introduces too much weight
1 parent 414c265 commit 180310c

File tree

2 files changed

+8
-19
lines changed

2 files changed

+8
-19
lines changed

packages/runtime-dom/src/patchProp.ts

+8-14
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,7 @@ import { patchStyle } from './modules/style'
33
import { patchAttr } from './modules/attrs'
44
import { patchDOMProp } from './modules/props'
55
import { patchEvent } from './modules/events'
6-
import {
7-
isOn,
8-
isString,
9-
isFunction,
10-
isModelListener,
11-
isFormTag
12-
} from '@vue/shared'
6+
import { isOn, isString, isFunction, isModelListener } from '@vue/shared'
137
import { RendererOptions } from '@vue/runtime-core'
148

159
const nativeOnRE = /^on[a-z]/
@@ -99,9 +93,9 @@ function shouldSetAsProp(
9993
return false
10094
}
10195

102-
// #1787, #2840 the form property is readonly and can only be set as an
103-
// attribute using a string value
104-
if (key === 'form' && isFormTag(el.tagName)) {
96+
// #1787, #2840 form property on form elements is readonly and must be set as
97+
// attribute.
98+
if (key === 'form') {
10599
return false
106100
}
107101

@@ -110,13 +104,13 @@ function shouldSetAsProp(
110104
return false
111105
}
112106

113-
// native onclick with string value, must be set as attribute
114-
if (nativeOnRE.test(key) && isString(value)) {
107+
// #2766 <textarea type> must be set as attribute
108+
if (key === 'type' && el.tagName === 'TEXTAREA') {
115109
return false
116110
}
117111

118-
// DOMprop "type" is readonly on textarea elements: https://github.com/vuejs/vue-next/issues/2766
119-
if (key === 'type' && el.tagName === 'TEXTAREA') {
112+
// native onclick with string value, must be set as attribute
113+
if (nativeOnRE.test(key) && isString(value)) {
120114
return false
121115
}
122116

packages/shared/src/domTagConfig.ts

-5
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@ const SVG_TAGS =
3030
const VOID_TAGS =
3131
'area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr'
3232

33-
const FORM_TAGS =
34-
'button,datalist,fieldset,input,keygen,label,legend,meter,optgroup,option,' +
35-
'output,progress,select,textarea'
36-
3733
export const isHTMLTag = /*#__PURE__*/ makeMap(HTML_TAGS)
3834
export const isSVGTag = /*#__PURE__*/ makeMap(SVG_TAGS)
3935
export const isVoidTag = /*#__PURE__*/ makeMap(VOID_TAGS)
40-
export const isFormTag = /*#__PURE__*/ makeMap(FORM_TAGS, true)

0 commit comments

Comments
 (0)