From f6924a4a6fad062a90abe1ef44695b985fb8947d Mon Sep 17 00:00:00 2001 From: campaign Date: Tue, 19 Feb 2013 15:43:57 +0800 Subject: [PATCH] by zhanyi --- _src/core/filternode.js | 14 +++++++++++++- _src/core/node.js | 27 ++++++++++++--------------- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/_src/core/filternode.js b/_src/core/filternode.js index 50dc9aa3..fd203682 100644 --- a/_src/core/filternode.js +++ b/_src/core/filternode.js @@ -44,7 +44,10 @@ var filterNode = UE.filterNode = function () { }); tmpVal = tmpCssStyle.join(';') } - tmpAttrs[a] = tmpVal; + if(tmpVal !== ""){ + tmpAttrs[a] = tmpVal; + } + } node.attrs = tmpAttrs; } @@ -80,6 +83,15 @@ var filterNode = UE.filterNode = function () { } return function(root,rules){ + if(utils.isEmptyObject(rules)){ + return root; + } + var val; + if(val = rules['-']){ + utils.each(val.split(' '),function(k){ + rules[k] = '-' + }) + } for(var i= 0,ci;ci=root.children[i];){ filterNode(ci,rules); if(ci.parentNode){ diff --git a/_src/core/node.js b/_src/core/node.js index fe667a06..bb86efc5 100644 --- a/_src/core/node.js +++ b/_src/core/node.js @@ -229,34 +229,31 @@ }, insertBefore:function (target, source) { if (this.children) { + if(target.parentNode){ + target.parentNode.removeChild(target); + } for (var i = 0, ci; ci = this.children[i]; i++) { - if (ci === target) { - this.children.splice(i, 1); - i--; - } if (ci === source) { this.children.splice(i, 0, target); target.parentNode = this; - i++; + return target; } } - return target; + } }, insertAfter:function (target, source) { if (this.children) { + if(target.parentNode){ + target.parentNode.removeChild(target); + } for (var i = 0, ci; ci = this.children[i]; i++) { - if (ci === target) { - this.children.splice(i, 1); - i--; - } if (ci === source) { - this.children.splice(i + 1, 1, target); + this.children.splice(i + 1, 0, target); target.parentNode = this; - i = i + 2; - + return target; } - return target; + } } }, @@ -341,7 +338,7 @@ } var reg = new RegExp(name + ':([^;]+)'); var match = cssStyle.match(reg); - if (match[0]) { + if (match && match[0]) { return match[1] } return ''; -- GitLab