Re: modifying the DOM WAS: Node append

On 10/3/11 5:30 PM, Ojan Vafai wrote:
> Specifically, lets add the following methods to Node:
> prepend(nodeish) - Adds to the start of the node.
> append(nodeish) - Adds to the end of the node.
> before(nodeish) - Adds before the node.
> after(nodeish) - Adds after the node.
> replace(nodeish) - Replaces the node.
> remove() - Removes the node.

No matter what else, we _have_ to do the remove thing! 
foo.parentNode.removeChild(foo) is just .... <sigh>.

The only worry with adding these is on* attributes that might happen to 
use those barewords and expect to hit global scope.  Do we have any data 
on such things?  (Note that we've had problems with that sort of thing 
in the past, e.g. when inputs grew a 'list' property.)

> 1. node, string, array, nodelist
> 2. node, string, array, nodelist, number, bool, undefined, null
> 3. node, string, anything with a length property is treated as an array,
> anything else is toString'ed.

And for option 2 anything else throws?

Note that in webidl terms, "array", "nodelist", and "anything with a 
length property" are sort of the same thing last I checked....

-Boris

Received on Monday, 3 October 2011 21:40:08 UTC