[whatwg] createElement convenience method

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