|
@@ -208,8 +208,8 @@ define([
|
|
|
|
|
|
if (observer != null) {
|
|
|
this._observer = new observer(function (mutations) {
|
|
|
- $.each(mutations, self._syncA);
|
|
|
- $.each(mutations, self._syncS);
|
|
|
+ self._syncA();
|
|
|
+ self._syncS(null, mutations);
|
|
|
});
|
|
|
this._observer.observe(this.$element[0], {
|
|
|
attributes: true,
|
|
@@ -376,7 +376,7 @@ define([
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- Select2.prototype._syncSubtree = function (evt, mutations) {
|
|
|
+ Select2.prototype._isChangeMutation = function (evt, mutations) {
|
|
|
var changed = false;
|
|
|
var self = this;
|
|
|
|
|
@@ -404,7 +404,22 @@ define([
|
|
|
}
|
|
|
} else if (mutations.removedNodes && mutations.removedNodes.length > 0) {
|
|
|
changed = true;
|
|
|
+ } else if ($.isArray(mutations)) {
|
|
|
+ $.each(mutations, function(evt, mutation) {
|
|
|
+ if (self._isChangeMutation(evt, mutation)) {
|
|
|
+ // We've found a change mutation.
|
|
|
+ // Let's escape from the loop and continue
|
|
|
+ changed = true;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
+ return changed;
|
|
|
+ };
|
|
|
+
|
|
|
+ Select2.prototype._syncSubtree = function (evt, mutations) {
|
|
|
+ var changed = this._isChangeMutation(evt, mutations);
|
|
|
+ var self = this;
|
|
|
|
|
|
// Only re-pull the data if we think there is a change
|
|
|
if (changed) {
|