Skip to content

Commit c61bd6d

Browse files
committed
handle dom edge cases
1 parent caca583 commit c61bd6d

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

src/api/dom.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ exports.$after = function (target, cb, withTransition) {
8787
*/
8888

8989
exports.$remove = function (cb, withTransition) {
90+
if (!this.$el.parentNode) {
91+
return cb && cb()
92+
}
9093
var inDoc = this._isAttached && _.inDoc(this.$el)
9194
// if we are not in document, no need to check
9295
// for transitions
@@ -220,4 +223,4 @@ function before (el, target, vm, cb) {
220223
function remove (el, vm, cb) {
221224
_.remove(el)
222225
if (cb) cb()
223-
}
226+
}

src/directives/component.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,9 @@ module.exports = {
227227
break
228228
case 'out-in':
229229
self.remove(current, function () {
230-
target.$before(self.anchor, cb)
230+
if (!target._isDestroyed) {
231+
target.$before(self.anchor, cb)
232+
}
231233
})
232234
break
233235
default:

test/unit/specs/api/dom_spec.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,11 @@ if (_.inBrowser) {
176176
expect(spy.calls.count()).toBe(1)
177177
})
178178

179+
it('detached', function () {
180+
vm.$remove(spy)
181+
expect(spy.calls.count()).toBe(1)
182+
})
183+
179184
})
180185

181186
describe('$nextTick', function () {
@@ -198,4 +203,4 @@ if (_.inBrowser) {
198203
})
199204

200205
})
201-
}
206+
}

0 commit comments

Comments
 (0)