Skip to content

Commit

Permalink
work around chrome and mutation observer bug. fixes select2#1099
Browse files Browse the repository at this point in the history
  • Loading branch information
ivaynberg committed Apr 27, 2013
1 parent 53fff96 commit 78139a8
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions select2.js
Original file line number Diff line number Diff line change
Expand Up @@ -961,12 +961,19 @@ the specific language governing permissions and limitations under the Apache Lic

// mozilla and IE
el.bind("propertychange.select2 DOMAttrModified.select2", sync);


// hold onto a reference of the callback to work around a chromium bug
if (this.mutationCallback === undefined) {
this.mutationCallback = function (mutations) {
mutations.forEach(sync);
}
}

// safari and chrome
if (typeof WebKitMutationObserver !== "undefined") {
if (this.propertyObserver) { delete this.propertyObserver; this.propertyObserver = null; }
this.propertyObserver = new WebKitMutationObserver(function (mutations) {
mutations.forEach(sync);
});
this.propertyObserver = new WebKitMutationObserver(this.mutationCallback);
this.propertyObserver.observe(el.get(0), { attributes:true, subtree:false });
}
},
Expand Down

0 comments on commit 78139a8

Please sign in to comment.