component / dom

DOM traversal, manipulation and events aggregate library (like jQuery)
228 stars 49 forks source link

wrapping dom tree traversal methods? #23

Closed ericgj closed 11 years ago

ericgj commented 11 years ago

I started a lib basically ripping out prev(), next(), prevAll(), etc. from jquery.. do you know if there is already a component that has these? Also do you think it belongs in here.

The main advantage I see of wrapping el.previousElementSibling etc. is dealing with nulls. Right now you have to do klutzy stuff like this to wrap potentially null els (not sure if this is even right):

var x = el.previousElementSibling; 
x = x ? dom(x) : dom([]);

The other thing is jquery code uses the backwards-compatible previousSibling, etc., not sure if that matters (I don't particularly care).

tj commented 11 years ago

for smaller stuff like that I'd probably just inline them in this lib, they're small enough that you wouldn't gain a whole lot other than indirection