Skip to content

Commit

Permalink
dom
Browse files Browse the repository at this point in the history
  • Loading branch information
chjj committed Aug 11, 2011
1 parent 481f742 commit baa2e19
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions lib/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,24 +228,18 @@ DOM.implement({
return DOM(out);
},
ancestors: function(el) {
var out = []
, i;

(function ancestors(el) {
el = el.parentNode;
if (el) while (el.previousSibling
&& (el = el.previousSibling));
var out = [];

while (el = el.parentNode) {
while (el.previousSibling) {
el = el.previousSibling;
}
while (el) {
if (el.nodeType === 1) {
i = out.length;
while (i--) if (out[i] === el) break;
if (i === -1) out.push(el);
ancestors(el);
}
out.push(el);
if (!el.nextSibling) break;
el = el.nextSibling;
}
})(el);
}

return DOM(out);
},
Expand Down

0 comments on commit baa2e19

Please sign in to comment.