Skip to content

Commit d2eb1c7

Browse files
committed
minor optimizations
1 parent 794143d commit d2eb1c7

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/jquery.observable/jquery.observable.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* http://www.opensource.org/licenses/mit-license.php
77
* http://www.gnu.org/licenses/gpl.html
88
*
9-
* @version 1.0.1
9+
* @version 1.0.2
1010
* @requires $.identify
1111
* @requires $.inherit
1212
*/
@@ -41,6 +41,7 @@ var storageExpando = '__' + +new Date + 'storage',
4141
*/
4242
on : function(e, data, fn, ctx, _special) {
4343

44+
var _this = this;
4445
if(typeof e == 'string') {
4546
if($.isFunction(data)) {
4647
ctx = fn;
@@ -49,13 +50,13 @@ var storageExpando = '__' + +new Date + 'storage',
4950
}
5051

5152
var id = getFnId(fn, ctx),
52-
storage = this[storageExpando] || (this[storageExpando] = {}),
53+
storage = _this[storageExpando] || (_this[storageExpando] = {}),
5354
eList = e.split(' '),
5455
i = 0,
5556
eStorage;
5657

5758
while(e = eList[i++]) {
58-
e = this.buildEventName(e);
59+
e = _this.buildEventName(e);
5960
eStorage = storage[e] || (storage[e] = { ids : {}, list : {} });
6061

6162
if(!(id in eStorage.ids)) {
@@ -72,13 +73,12 @@ var storageExpando = '__' + +new Date + 'storage',
7273
}
7374
}
7475
} else {
75-
var _this = this;
7676
$.each(e, function(e, fn) {
7777
_this.on(e, fn, data, _special);
7878
});
7979
}
8080

81-
return this;
81+
return _this;
8282

8383
},
8484

@@ -97,15 +97,16 @@ var storageExpando = '__' + +new Date + 'storage',
9797
*/
9898
un : function(e, fn, ctx) {
9999

100+
var _this = this;
100101
if(typeof e == 'string' || typeof e == 'undefined') {
101-
var storage = this[storageExpando];
102+
var storage = _this[storageExpando];
102103
if(storage) {
103104
if(e) { // если передан тип события
104105
var eList = e.split(' '),
105106
i = 0,
106107
eStorage;
107108
while(e = eList[i++]) {
108-
e = this.buildEventName(e);
109+
e = _this.buildEventName(e);
109110
if(eStorage = storage[e]) {
110111
if(fn) { // если передан конкретный обработчик
111112
var id = getFnId(fn, ctx),
@@ -133,22 +134,21 @@ var storageExpando = '__' + +new Date + 'storage',
133134
delete ids[id];
134135
}
135136
} else {
136-
delete this[storageExpando][e];
137+
delete _this[storageExpando][e];
137138
}
138139
}
139140
}
140141
} else {
141-
delete this[storageExpando];
142+
delete _this[storageExpando];
142143
}
143144
}
144145
} else {
145-
var _this = this;
146146
$.each(e, function(e, fn) {
147147
_this.un(e, fn, ctx);
148148
});
149149
}
150150

151-
return this;
151+
return _this;
152152

153153
},
154154

@@ -190,7 +190,7 @@ var storageExpando = '__' + +new Date + 'storage',
190190
}
191191
}
192192

193-
return this;
193+
return _this;
194194

195195
}
196196

src/jquery.observable/jquery.observable.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)