Re: Proposed errata for DOM2 Range regarding insertNode()

Since the idea of making it clear that insertNode() inserts the node 
inside the range even if the range is collapsed seems to have received a 
somewhat positive response, I'd like to propose the following actual 
errata text:

| DOM Level 2 Traversal and Range
| 
| range-2. 2008-06-... [clarification]. Range.insertNode
| 
| The sentence:
| 
|    The node is inserted at the start boundary-point of the Range, without 
|    modifying it.
| 
| Should read:
| 
|    The node is inserted at the start boundary-point of the Range, without 
|    modifying the start boundary-point. If the range is collapsed, the 
|    offset of the Range's end boundary-point will be increased so that it 
|    is before the same node or character as it was before the insertion.

This uses the language style of the spec as it stands today (we can worry 
about making the spec use RFC2119 terminology when we rewrite it later; 
doing that now too would be a big rathole IMHO).

Chaals, can we put this to the working group as a proposed errata?


On Wed, 14 May 2008, Boris Zbarsky wrote:
> > >
> > > [discussion regarding mutation event timing]
> >
> > For example regular old insertions and deletions near ranges cause 
> > changes to the range values but the spec doesn't say if this is before 
> > or after the events.
> 
> I think it's pretty clear that it should be when the actual mutation 
> occurs (so before the events for insert cases and after for removal 
> cases), but that does mean that one can't implement Range on top of DOM 
> MutationEvents.  Then again, there's no much one can implement on top of 
> them, so that's OK, I think.
> 
> > It seems that for sanity we should say it happens before, if we 
> > specify this. Should we do this as a separate errata?
> 
> I just wanted to point out that we have to be very careful in how we 
> phrase this erratum (which I agree is a possibly useful one): we 
> basically want to perform the insertion, then before firing the mutation 
> event adjust the insertion endpoint after all the nodes we just 
> inserted.  Or something.  In a UA that would fire multiple events here 
> when inserting a DocumentFragment, we might lose no matter what we try 
> to do.

I'm not sure what to do about mutation events. I think it may be wiser to 
punt on this or at least deal with it in a separate errata.


On Fri, 23 May 2008, Olli Pettay wrote:
>
> So I'm not sure the errata for this issue is actually needed.

It seems to me that everyone agrees that insertNode() was always intended 
to insert a node _into_ the range, and that the collapsed case was simply 
lost between the cracks when the DOM WG was writing the spec (much as was 
interaction with mutation events, for instance). While I agree that the 
spec could be read as saying that the node is inserted after the range 
when it is collapsed, I don't think we want that behaviour, nor that it 
was intended. Do you actually think that behaviour is preferred to the 
insertion behaviour?

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

Received on Wednesday, 28 May 2008 01:53:26 UTC