Skip to content

Commit 664cee6

Browse files
committed
refactor: small tweak to #6910
1 parent 58a39df commit 664cee6

File tree

1 file changed

+3
-9
lines changed
  • src/platforms/web/runtime/directives

1 file changed

+3
-9
lines changed

src/platforms/web/runtime/directives/model.js

+3-9
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55

66
import { isTextInputType } from 'web/util/element'
77
import { looseEqual, looseIndexOf } from 'shared/util'
8-
import { warn, isAndroid, isIE9, isIE, isEdge } from 'core/util/index'
98
import { mergeVNodeHook } from 'core/vdom/helpers/index'
10-
import { emptyNode } from 'core/vdom/patch'
9+
import { warn, isAndroid, isIE9, isIE, isEdge } from 'core/util/index'
1110

1211
/* istanbul ignore if */
1312
if (isIE9) {
@@ -24,7 +23,7 @@ const directive = {
2423
inserted (el, binding, vnode, oldVnode) {
2524
if (vnode.tag === 'select') {
2625
// #6903
27-
if (oldVnode !== emptyNode && !hasDirective(oldVnode, 'model')) {
26+
if (oldVnode.elm && !oldVnode.elm._vOptions) {
2827
mergeVNodeHook(vnode.data.hook || (vnode.data.hook = {}), 'postpatch', () => {
2928
directive.componentUpdated(el, binding, vnode)
3029
})
@@ -51,6 +50,7 @@ const directive = {
5150
}
5251
}
5352
},
53+
5454
componentUpdated (el, binding, vnode) {
5555
if (vnode.tag === 'select') {
5656
setSelected(el, binding, vnode.context)
@@ -146,10 +146,4 @@ function trigger (el, type) {
146146
el.dispatchEvent(e)
147147
}
148148

149-
function hasDirective (vnode, dirname) {
150-
return vnode.data &&
151-
vnode.data.directives &&
152-
vnode.data.directives.some(dir => dir.name === dirname)
153-
}
154-
155149
export default directive

0 commit comments

Comments
 (0)