Re: Optimize setting textContent?

On 2/8/12 3:23 PM, Adam Klein wrote:
> But the current proposal, of reusing the first child if it happens to
> be a text node, seems particularly weird to me. For one thing, it
> would then be possible to remove all but one child of an element,
> whereas previously any operation that removed children either removed
> one or removed all.

I'm not sure that's true.  First of all, removing all but one child 
could report mutations one by one to the mutation observers.  But even 
if it does not, you can already remove arbitrary contiguous subsets of 
kids in an "atomic" operation via Range operations like deleteContents 
or extractContents.  Whatever those do wrt mutation observers is what 
"remove all but the first child" should do.  It could even be defined in 
terms of positioning a range and calling deleteContents on it, per spec.

-Boris

Received on Wednesday, 8 February 2012 20:33:16 UTC