@@ -5,6 +5,7 @@ import { patchDOMProp } from './modules/props'
5
5
import { patchEvent } from './modules/events'
6
6
import { isOn , isString , isFunction } from '@vue/shared'
7
7
import { RendererOptions } from '@vue/runtime-core'
8
+ import { chdir } from 'process'
Has a conversation. Original line has a conversation. 8
9
9
10
const nativeOnRE = / ^ o n [ a - z ] /
10
11
@@ -38,26 +39,7 @@ export const patchProp: DOMRendererOptions['patchProp'] = (
38
39
if ( ! key . startsWith ( 'onUpdate:' ) ) {
39
40
patchEvent ( el , key , prevValue , nextValue , parentComponent )
40
41
}
41
- } else if (
42
- // spellcheck and draggable are numerated attrs, however their
43
- // corresponding DOM properties are actually booleans - this leads to
44
- // setting it with a string "false" value leading it to be coerced to
45
- // `true`, so we need to always treat them as attributes.
46
- // Note that `contentEditable` doesn't have this problem: its DOM
47
- // property is also enumerated string values.
48
- key !== 'spellcheck' &&
49
- key !== 'draggable' &&
50
- ( isSVG
51
- ? // most keys must be set as attribute on svg elements to work
52
- // ...except innerHTML
53
- key === 'innerHTML' ||
54
- // or native onclick with function values
55
- ( key in el && nativeOnRE . test ( key ) && isFunction ( nextValue ) )
56
- : // for normal html elements, set as a property if it exists
57
- key in el &&
58
- // except native onclick with string values
59
- ! ( nativeOnRE . test ( key ) && isString ( nextValue ) ) )
60
- ) {
42
+ } else if ( shouldSetAsProp ( el , key , nextValue , isSVG ) ) {
61
43
patchDOMProp (
62
44
el ,
63
45
key ,
@@ -82,3 +64,45 @@ export const patchProp: DOMRendererOptions['patchProp'] = (
82
64
break
83
65
}
84
66
}
67
+
68
+ function shouldSetAsProp (
69
+ el : Element ,
70
+ key : string ,
71
+ value : unknown ,
72
+ isSVG : boolean
73
+ ) {
74
+ if ( isSVG ) {
75
+ // most keys must be set as attribute on svg elements to work
76
+ // ...except innerHTML
77
+ if ( key === 'innerHTML' ) {
78
+ return true
79
+ }
80
+ // or native onclick with function values
81
+ if ( key in el && nativeOnRE . test ( key ) && isFunction ( value ) ) {
82
+ return true
83
+ }
84
+ return false
85
+ }
86
+
87
+ // spellcheck and draggable are numerated attrs, however their
88
+ // corresponding DOM properties are actually booleans - this leads to
89
+ // setting it with a string "false" value leading it to be coerced to
90
+ // `true`, so we need to always treat them as attributes.
91
+ // Note that `contentEditable` doesn't have this problem: its DOM
92
+ // property is also enumerated string values.
93
+ if ( key === 'spellcheck' || key === 'draggable' ) {
94
+ return false
95
+ }
96
+
97
+ // #1526 <input list> must be set as attribute
98
+ if ( key === 'list' && el . tagName === 'INPUT' ) {
99
+ return false
100
+ }
101
+
102
+ // native onclick with string value, must be set as attribute
103
+ if ( nativeOnRE . test ( key ) && isString ( value ) ) {
104
+ return false
105
+ }
106
+
107
+ return key in el
108
+ }