W3C home > Mailing lists > Public > public-html@w3.org > October 2007

Re: [whatwg] createElement convenience method

From: Cameron McCormack <cam@mcc.id.au>
Date: Mon, 22 Oct 2007 17:35:50 +1000
To: public-html@w3.org
Message-ID: <20071022073550.GA15328@arc.mcc.id.au>

Thomas Broyer:
> How would you test that it is available?
> 
> <script>if ("getElementsByClassName" in document) { ... }</script>
> or
> <script>if (document.getElementsByClassName) { ... }</script>
> work, but how would you test that createElement and/or createElementNS
> can take an additional argument?

If document.getElementsByClassName is an actual Function, you could test
that document.getElementsByClassName.length == 2.

> createElementWithTextContent could work, but then you'd also want a
> createAttributeWithValue.
> 
> I doubt though there would be a huge advantage over doing:
>     var link_to_add = document.createElement("a");
>     link_to_add.textContent = the_text.nodeValue;

Agreed.

-- 
Cameron McCormack, http://mcc.id.au/
	xmpp:heycam@jabber.org  ▪  ICQ 26955922  ▪  MSN cam@mcc.id.au
Received on Monday, 22 October 2007 07:36:06 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 7 December 2009 10:40:04 GMT