W3C home > Mailing lists > Public > public-webapps@w3.org > October to December 2008

Web DOM Core: createElement convenience method (fwd)

From: Ian Hickson <ian@hixie.ch>
Date: Wed, 26 Nov 2008 07:14:50 +0000 (UTC)
To: public-webapps@w3.org
Cc: Keryx Web <webmaster@keryx.se>
Message-ID: <Pine.LNX.4.62.0811260713020.17414@hixie.dreamhostps.com>

Included below is feedback received on the WHATWG list for a proposed 
extension to createElement(). Since this applies to all of DOM Core, I 
haven't added it to HTML5, but I pass it on in case it is something that 
would apply to Web DOM Core.

FWIW, personally what I would find quite convenient too is an overloaded 
version of appendChild() that took a string, and automatically called 
document.createTextNode() on that string.

Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

---------- Forwarded message ----------
Subject: [whatwg] createElement convenience method
From: Keryx Web <webmaster@keryx.se>
To: WHAT working group <whatwg@lists.whatwg.org>
Date: Sat, 20 Oct 2007 15:27:45 +0200

Hello again!

I was putting together a page of exercices for my students. It's in Swedish and
mirrored at http://gunther.ne.keryx.se/datagrund-ovningar/

This page must work when delivered from the file system so I can't use my
beloved PHP. However, I missed one feature like crazy. Consider this:

var link_to_add  = document.createElement("a");
var link_text    = document.createTextNode(the_text.nodeValue);

If PHP:s convenience additions to the W3C DOM were made standard (and
implemented in browsers) it could have been:

var link_to_add  = document.createElement("a",the_text.nodeValue);

What I propose is this second text-parameter to the createElement method (or a
third for createElementNS).

See http://se.php.net/manual/en/function.dom-domdocument-createelement.php

Has the standardization of this functionality ever been discussed? If so, can
someone point me to that discussion?

Lars Gunther

P.S In PHP I can also get the text between start- and end-tags of an element


instead of


Even if I've yet to see any bad repercussions from this convenient shortcut, I
could imagine it is a bit more shaky...
Received on Wednesday, 26 November 2008 07:15:26 UTC

This archive was generated by hypermail 2.3.1 : Friday, 27 October 2017 07:26:12 UTC