Skip to content

Commit 78139a8

Browse files
committed
work around chrome and mutation observer bug. fixes select2#1099
1 parent 53fff96 commit 78139a8

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

select2.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -961,12 +961,19 @@ the specific language governing permissions and limitations under the Apache Lic
961961

962962
// mozilla and IE
963963
el.bind("propertychange.select2 DOMAttrModified.select2", sync);
964+
965+
966+
// hold onto a reference of the callback to work around a chromium bug
967+
if (this.mutationCallback === undefined) {
968+
this.mutationCallback = function (mutations) {
969+
mutations.forEach(sync);
970+
}
971+
}
972+
964973
// safari and chrome
965974
if (typeof WebKitMutationObserver !== "undefined") {
966975
if (this.propertyObserver) { delete this.propertyObserver; this.propertyObserver = null; }
967-
this.propertyObserver = new WebKitMutationObserver(function (mutations) {
968-
mutations.forEach(sync);
969-
});
976+
this.propertyObserver = new WebKitMutationObserver(this.mutationCallback);
970977
this.propertyObserver.observe(el.get(0), { attributes:true, subtree:false });
971978
}
972979
},

0 commit comments

Comments
 (0)