refactor(runtime-dom): avoid form attribtue tag check
the tag check while technically stricter, is not really necessary and introduces too much weight
This commit is contained in:
parent
414c265dd9
commit
180310cbe9
@ -3,13 +3,7 @@ import { patchStyle } from './modules/style'
|
|||||||
import { patchAttr } from './modules/attrs'
|
import { patchAttr } from './modules/attrs'
|
||||||
import { patchDOMProp } from './modules/props'
|
import { patchDOMProp } from './modules/props'
|
||||||
import { patchEvent } from './modules/events'
|
import { patchEvent } from './modules/events'
|
||||||
import {
|
import { isOn, isString, isFunction, isModelListener } from '@vue/shared'
|
||||||
isOn,
|
|
||||||
isString,
|
|
||||||
isFunction,
|
|
||||||
isModelListener,
|
|
||||||
isFormTag
|
|
||||||
} from '@vue/shared'
|
|
||||||
import { RendererOptions } from '@vue/runtime-core'
|
import { RendererOptions } from '@vue/runtime-core'
|
||||||
|
|
||||||
const nativeOnRE = /^on[a-z]/
|
const nativeOnRE = /^on[a-z]/
|
||||||
@ -99,9 +93,9 @@ function shouldSetAsProp(
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// #1787, #2840 the form property is readonly and can only be set as an
|
// #1787, #2840 form property on form elements is readonly and must be set as
|
||||||
// attribute using a string value
|
// attribute.
|
||||||
if (key === 'form' && isFormTag(el.tagName)) {
|
if (key === 'form') {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,15 +104,15 @@ function shouldSetAsProp(
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// #2766 <textarea type> must be set as attribute
|
||||||
|
if (key === 'type' && el.tagName === 'TEXTAREA') {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// native onclick with string value, must be set as attribute
|
// native onclick with string value, must be set as attribute
|
||||||
if (nativeOnRE.test(key) && isString(value)) {
|
if (nativeOnRE.test(key) && isString(value)) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// DOMprop "type" is readonly on textarea elements: https://github.com/vuejs/vue-next/issues/2766
|
|
||||||
if (key === 'type' && el.tagName === 'TEXTAREA') {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
return key in el
|
return key in el
|
||||||
}
|
}
|
||||||
|
@ -30,11 +30,6 @@ const SVG_TAGS =
|
|||||||
const VOID_TAGS =
|
const VOID_TAGS =
|
||||||
'area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr'
|
'area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr'
|
||||||
|
|
||||||
const FORM_TAGS =
|
|
||||||
'button,datalist,fieldset,input,keygen,label,legend,meter,optgroup,option,' +
|
|
||||||
'output,progress,select,textarea'
|
|
||||||
|
|
||||||
export const isHTMLTag = /*#__PURE__*/ makeMap(HTML_TAGS)
|
export const isHTMLTag = /*#__PURE__*/ makeMap(HTML_TAGS)
|
||||||
export const isSVGTag = /*#__PURE__*/ makeMap(SVG_TAGS)
|
export const isSVGTag = /*#__PURE__*/ makeMap(SVG_TAGS)
|
||||||
export const isVoidTag = /*#__PURE__*/ makeMap(VOID_TAGS)
|
export const isVoidTag = /*#__PURE__*/ makeMap(VOID_TAGS)
|
||||||
export const isFormTag = /*#__PURE__*/ makeMap(FORM_TAGS, true)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user