- From: Anne van Kesteren <annevk@opera.com>
- Date: Fri, 16 Sep 2011 17:13:20 +0200
- To: www-dom@w3.org, "Erik Arvidsson" <arv@chromium.org>
- Cc: "Ojan Vafai" <ojan@chromium.org>
On Thu, 15 Sep 2011 21:37:13 +0200, Erik Arvidsson <arv@chromium.org> wrote: > It would be useful to add an append method to the Node interface. It > would work as the rest args in Element.create where it would just > append Nodes to the end of the childNodes and it would toString() and > create Text nodes for everything else. > > var element = ...; > element.append(otherNode, "some text", 42, {toString: function() { > return 'x' }}); > > On this topic, it would be useful if the current DOM methods > (appendChild, insertBefore and replaceChild) could all be changed to > support Strings too. This seems like a nice plan. Note that if we overload appendChild with DOMString it would throw for anything non-Node non-DOMString. We could make everything stringify by using a special IDL operator (e.g. as XMLHttpRequest does for send()), but depending on what we want to do in the future that might make extensions harder. Maybe instead of a new append() method we could simply make the methods that already accept DocumentFragMent accept arrays too? The arrays would be valid as long as they only contain nodes DocumentFragment can contain or DOMString. Let me know what you think. -- Anne van Kesteren http://annevankesteren.nl/
Received on Friday, 16 September 2011 15:14:28 UTC