Skip to content

Commit

Permalink
fix(nipple): control dom presence before add or remove
Browse files Browse the repository at this point in the history
  • Loading branch information
yoannmoinet committed Sep 29, 2015
1 parent 2deb42c commit 7cc1d8c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/nipple.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ Nipple.prototype.applyStyles = function (styles) {

// Inject the Nipple instance into DOM.
Nipple.prototype.addToDom = function () {
if (this.options.dataOnly) {
// We're not adding it if we're dataOnly or already in dom.
if (this.options.dataOnly || document.contains(this.ui.el)) {
return;
}
this.manager.options.zone.appendChild(this.ui.el);
Expand All @@ -158,7 +159,7 @@ Nipple.prototype.addToDom = function () {

// Remove the Nipple instance from DOM.
Nipple.prototype.removeFromDom = function () {
if (this.options.dataOnly) {
if (this.options.dataOnly || !document.contains(this.ui.el)) {
return;
}
this.manager.options.zone.removeChild(this.ui.el);
Expand Down

0 comments on commit 7cc1d8c

Please sign in to comment.