Permalink
Browse files

num == null --> !arguments.length

  • Loading branch information...
1 parent 8e50222 commit eaeb373680541252418f4912a3b9cbaf828024aa @RubyLouvre committed Mar 5, 2013
Showing with 12 additions and 32 deletions.
  1. +3 −13 node.js
  2. +9 −19 node_neo.js
View
16 node.js
@@ -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:进入选择器模块
@@ -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);
@@ -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'
};
@@ -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;
}
View
@@ -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);
@@ -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() {
@@ -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'
};

0 comments on commit eaeb373

Please sign in to comment.