Skip to content

Commit 2133129

Browse files
committed
keyword this inside closures referring to wrong object
1 parent ea3c676 commit 2133129

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

select2.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,7 +1076,7 @@ the specific language governing permissions and limitations under the Apache Lic
10761076
*/
10771077
// abstract
10781078
monitorSource: function () {
1079-
var el = this.opts.element, observer;
1079+
var el = this.opts.element, observer, self = this;
10801080

10811081
el.on("change.select2", this.bind(function (e) {
10821082
if (this.opts.element.data("select2-change-triggered") !== true) {
@@ -1106,7 +1106,7 @@ the specific language governing permissions and limitations under the Apache Lic
11061106
// IE8-10 (IE9/10 won't fire propertyChange via attachEventListener)
11071107
if (el.length && el[0].attachEvent) {
11081108
el.each(function() {
1109-
this.attachEvent("onpropertychange", this._sync);
1109+
this.attachEvent("onpropertychange", self._sync);
11101110
});
11111111
}
11121112

@@ -1115,7 +1115,7 @@ the specific language governing permissions and limitations under the Apache Lic
11151115
if (observer !== undefined) {
11161116
if (this.propertyObserver) { delete this.propertyObserver; this.propertyObserver = null; }
11171117
this.propertyObserver = new observer(function (mutations) {
1118-
mutations.forEach(this._sync);
1118+
mutations.forEach(self._sync);
11191119
});
11201120
this.propertyObserver.observe(el.get(0), { attributes:true, subtree:false });
11211121
}

0 commit comments

Comments
 (0)