Skip to content

Commit

Permalink
num == null --> !arguments.length
Browse files Browse the repository at this point in the history
  • Loading branch information
RubyLouvre committed Mar 5, 2013
1 parent 8e50222 commit eaeb373
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 32 deletions.
16 changes: 3 additions & 13 deletions node.js
Expand Up @@ -56,7 +56,7 @@ define("node", ["support", "class", "query", "data"].concat(top.dispatchEvent ?
expr = expr.trim();
if(expr.charAt(0) === "<" && expr.charAt(expr.length - 1) === ">" && expr.length >= 3) {
nodes = $.parseHTML(expr, doc); //分支5: 动态生成新节点
nodes = nodes.childNodes
nodes = nodes.childNodes;
} else if(rtag.test(expr)) { //分支6: getElementsByTagName
nodes = scope[TAGS](expr);
} else { //分支7:进入选择器模块
Expand Down Expand Up @@ -97,7 +97,7 @@ define("node", ["support", "class", "query", "data"].concat(top.dispatchEvent ?
return this.labor($.slice(this, a, b));
},
get: function(num) { //取得与索引值相对应的节点,若为负数从后面取起,如果不传,则返回节点集的纯数组
return num == null ? this.valueOf() : this[num < 0 ? this.length + num : num];
return !arguments.length ? this.valueOf() : this[num < 0 ? this.length + num : num];
},
eq: function(i) { //取得与索引值相对应的节点,并构成mass对象返回
return i === -1 ? this.slice(i) : this.slice(i, +i + 1);
Expand Down Expand Up @@ -236,16 +236,6 @@ define("node", ["support", "class", "query", "data"].concat(top.dispatchEvent ?
//http://dev.opera.com/articles/view/opera-mobile-emulator-experimental-webkit-prefix-support/
var prefixes = ['', '-webkit-', '-o-', '-moz-', '-ms-', 'WebKit-', 'moz-', "webkit-", 'ms-', '-khtml-'];
var cssMap = { //支持检测 WebKitMutationObserver WebKitCSSMatrix mozMatchesSelector ,webkitRequestAnimationFrame
c: "color",
h: "height",
o: "opacity",
w: "width",
x: "left",
y: "top",
fs: "fontSize",
st: "scrollTop",
sl: "scrollLeft",
bgc: "backgroundColor",
"float": $.support.cssFloat ? 'cssFloat' : 'styleFloat'
};

Expand Down Expand Up @@ -274,7 +264,7 @@ define("node", ["support", "class", "query", "data"].concat(top.dispatchEvent ?
var parent = node.parentNode;
if(parent) {
var array = $.query(expr, node.ownerDocument);
return array.indexOf(node) != -1;
return array.indexOf(node) !== -1;
}
return false;
}
Expand Down
28 changes: 9 additions & 19 deletions node_neo.js
Expand Up @@ -92,7 +92,7 @@ define("node", ["support", "class", "query", "data"], function($) {
return this.labor($.slice(this, a, b));
},
get: function(num) { //取得与索引值相对应的节点,若为负数从后面取起,如果不传,则返回节点集的纯数组
return num == null ? this.valueOf() : this[num < 0 ? this.length + num : num];
return !arguments.length ? this.valueOf() : this[num < 0 ? this.length + num : num];
},
eq: function(i) { //取得与索引值相对应的节点,并构成mass对象返回
return i === -1 ? this.slice(i) : this.slice(i, +i + 1);
Expand Down Expand Up @@ -185,7 +185,7 @@ define("node", ["support", "class", "query", "data"], function($) {
$.fn[method] = function() {
Array.prototype[method].apply(this, arguments);
return this;
}
};
});
"remove,empty,detach".replace($.rword, function(method) {
$.fn[method] = function() {
Expand All @@ -209,40 +209,30 @@ define("node", ["support", "class", "query", "data"], function($) {
}
}
return this;
}
};
});
//前导 前置 追加 后放 替换
"append,prepend,before,after,replace".replace($.rword, function(method) {
$.fn[method] = function(item) {
return manipulate(this, method, item, this.ownerDocument);
}
};
$.fn[method + "To"] = function(item) {
$(item, this.ownerDocument)[method](this);
return this;
}
};
});
//添加对jQuery insertAfter/insertBefore的兼容支持
$.fn.insertAfter = function(item) {
$.log("insertAfter is deprecated, instead of afterTo")
$.log("insertAfter is deprecated, instead of afterTo");
return this.afterTo(item);
}
};
$.fn.insertBefore = function(item) {
$.log("insertBefore is deprecated, instead of beforeTo")
$.log("insertBefore is deprecated, instead of beforeTo");
return this.beforeTo(item);
}
};
//http://dev.opera.com/articles/view/opera-mobile-emulator-experimental-webkit-prefix-support/
var prefixes = ['', '-webkit-', '-o-', '-moz-', '-ms-', 'WebKit-', 'moz-', "webkit-", 'ms-', '-khtml-'];
var cssMap = {//支持检测 WebKitMutationObserver WebKitCSSMatrix mozMatchesSelector ,webkitRequestAnimationFrame
c: "color",
h: "height",
o: "opacity",
w: "width",
x: "left",
y: "top",
fs: "fontSize",
st: "scrollTop",
sl: "scrollLeft",
bgc: "backgroundColor",
"float": $.support.cssFloat ? 'cssFloat' : 'styleFloat'
};

Expand Down

0 comments on commit eaeb373

Please sign in to comment.