Skip to content

Commit 08c33d7

Browse files
committed
Prevent race condition on rerendering
1 parent 407273e commit 08c33d7

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

index.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@ export default {
2828
},
2929
methods: {
3030
paint: function () {
31-
render(this.$el.parentNode.insertBefore(this._ = document.createElement('span'), this.$el).appendChild(this.$el), (function(_this) {
32-
return function (el) {
33-
_this.$el.parentNode.replaceChild(el, _this.$el)
34-
}
35-
})(this))
31+
(function ($el, _) {
32+
render($el.parentNode.insertBefore(_, $el).appendChild($el), function (el) {
33+
try {
34+
_.replaceChild(el, $el)
35+
} catch (_) {}
36+
})
37+
})(this.$el, this._ = document.createElement('span'))
3638
},
3739
reset: function () {
3840
this._.parentNode.replaceChild(this.$el, this._)

0 commit comments

Comments
 (0)