W3C home > Mailing lists > Public > whatwg@whatwg.org > October 2007

[whatwg] createElement convenience method

From: Keryx Web <webmaster@keryx.se>
Date: Mon, 22 Oct 2007 16:39:17 +0200
Message-ID: <471CB615.1050005@keryx.se>
Michael A. Puls II skrev:
 > On 10/20/07, Keryx Web <webmaster at keryx.se> wrote:
 >> 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);
 > You can do this:
 > Document.prototype.createElement = function (name, text) ---

Yes I can. And solutions such as this one is how I expect my intended 
suggestion to be made available to current browsers until they die out.

The main problem I see is that since JavaScript does not allow method 
overloading (?) there is no way to separate between the native 
createElement, with one parameter, and the overriding new method. One 
must also develop a check for the new two parameter capability to avoid 
unnecessary messing with the Document.prototype.

But I do think these things are solvable.

For clarity's sake: I did not suggest this in order to solve my personal 
problem today. I think this is a feature that will be of benefit to many!

Lars Gunther
Received on Monday, 22 October 2007 07:39:17 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:58:58 UTC