Let's say I want to get the paragraph containing the caret. I might have:

var node = window.getSelection().getRangeAt(0).startContainer;
// node is either Element or Text
var para =  (Object.isElement( node ) ?
                                $(node).up( 'p' )
                        :       $(node.parentNode).up( 'p' ));

So in the above I'm forced to go up the tree in two different ways 
(.parentNode and .up). If Element#up were Node#up, this could be simplified 
quite nicely:

var para = $(window.getSelection().getRangeAt(0).startContainer).up('p');

Generally, Prototype's policy of ignoring non-Element Nodes makes things 
simpler but there are times interacting with the browser when you have to deal 
with it giving you TextNodes and suddenly you're back to using standard DOM 
again.

Off the top of my head, some of the Element methods that could be provided for 
Nodes are:

up
ancestors
wrap
fire
getOffsetParent
observe
stopObserving

This wouldn't break compatibility because all the Element methods would behave 
the same as before.

-- 
Jim
my wiki ajaxification thing: http://wikizzle.org
my blog: http://jimhigson.blogspot.com/

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to 
prototype-core-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to