Skip to content

Commit fba5221

Browse files
committed
fix/optimize jQLight script
1 parent 22a5d3e commit fba5221

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

src/jqlight.lazyloadxt.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
(function (window, document, Element, undefined) {
77
'use strict';
88

9+
var prev_$ = window.$,
10+
DATAKEYPROP = '__jqlight_data__',
11+
matches = Element.matches || Element.matchesSelector || Element.mozMatchesSelector || Element.msMatchesSelector || Element.oMatchesSelector || Element.webkitMatchesSelector;
12+
913
function Wrapper(collection) {
1014
if (collection) {
1115
for (var i = 0, length = collection.length; i < length; i++) {
@@ -28,12 +32,10 @@
2832
length: 0
2933
};
3034

31-
$.fn.extend = $.extend = function (target) {
32-
var options, name, copy, i = 0, length = arguments.length;
33-
if (length <= 1) {
34-
target = this;
35-
} else {
36-
i = 1;
35+
$.fn.extend = $.extend = function () {
36+
var options, name, copy, target = this, i = 0, length = arguments.length;
37+
if (length > 1) {
38+
target = arguments[i++];
3739
}
3840
for (; i < length; i++) {
3941
options = arguments[i];
@@ -47,9 +49,6 @@
4749
return target;
4850
};
4951

50-
var prev_$ = window.$;
51-
window.$ = $;
52-
5352
$.extend({
5453
noConflict: function () {
5554
window.$ = prev_$;
@@ -105,7 +104,6 @@
105104
}
106105
});
107106

108-
var DATAKEYPROP = '__jqlight_data__';
109107
$.fn.extend({
110108
each: function (callback) {
111109
$.each(this, function (index, elem) {
@@ -207,6 +205,8 @@
207205
}
208206
});
209207

208+
window.$ = $;
209+
210210
function eachClass(obj, value, callback) {
211211
var classes = ( value || '' ).match(/\S+/g) || [],
212212
elem, cur, clazz, j, origValue, finalValue,
@@ -229,8 +229,6 @@
229229
return obj;
230230
}
231231

232-
var matches = Element.matches || Element.matchesSelector || Element.mozMatchesSelector || Element.msMatchesSelector || Element.oMatchesSelector || Element.webkitMatchesSelector;
233-
234232
function delegateHandler(selector, handler, event) {
235233
var node = event.target;
236234
while (node && node !== this) {

0 commit comments

Comments
 (0)