Re: Node append

On 4/10/11 4:01 AM, Erik Arvidsson wrote:
> On Sun, Oct 2, 2011 at 13:10, Aryeh Gregor<ayg@aryeh.name>  wrote:
>> On Sun, Oct 2, 2011 at 6:38 AM, Olli Pettay<Olli.Pettay@helsinki.fi>  wrote:
>>> Why? Why couldn't there be separate method(s) which take string/array etc
>>> and keep the old appendChild etc as they are now (in DOM 3, not in latest
>>> DOM 4 draft)
>> I concur with this.  Reasons to prefer separate methods are
>>
>> 1) It's unclear to someone reading the code whether the argument is
>> interpreted as plaintext or HTML.  If you do
>> node.appendChild('<div>'), is that supposed to append a text node or
>> an element?  Separate methods named things like appendText or
>> insertTextBefore would be much clearer, and not much longer if at all.
> I don't think it is unreasonable to expect some knowledge here,
> especially as it is safe for the developer to do the wrong thing. I
> would have been opposed if the incorrect thing was unsafe which is the
> case where HTML markup is allowed.
>
> It is just as unclear to me with insertBefore. Insert what before
> what? Maybe we should rename that to insertChildNodeBeforeChildNode
> then?
>
> Sorry, I just think it is time to make things less verbose so the JS
> libraries can shrink.

Can you demonstrate how it allows js libs to shrink?
If they adopt this feature they will at least have to *add* feature 
detection.

Sean

Received on Monday, 3 October 2011 20:53:35 UTC