Skip to content

Commit 9719cfa

Browse files
committed
do not unregister ref if parent is being destroyed
1 parent 31db052 commit 9719cfa

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/instance/lifecycle.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,14 @@ exports._destroy = function (remove, deferCleanup) {
133133
var parent = this.$parent
134134
if (parent && !parent._isBeingDestroyed) {
135135
parent.$children.$remove(this)
136+
// unregister ref
137+
var ref = this.$options._ref
138+
if (ref) {
139+
var scope = this._scope || this._context
140+
if (scope.$refs[ref] === this) {
141+
scope.$refs[ref] = null
142+
}
143+
}
136144
}
137145
// remove self from owner fragment
138146
if (this._frag) {
@@ -156,14 +164,6 @@ exports._destroy = function (remove, deferCleanup) {
156164
while (i--) {
157165
this._watchers[i].teardown()
158166
}
159-
// unregister ref
160-
var ref = this.$options._ref
161-
if (ref) {
162-
var scope = this._scope || this._context
163-
if (scope.$refs[ref] === this) {
164-
scope.$refs[ref] = null
165-
}
166-
}
167167
// remove reference to self on $el
168168
if (this.$el) {
169169
this.$el.__vue__ = null

0 commit comments

Comments
 (0)