This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 27488 - Steps 14-5 and 17-5 of the DOM 4 Range cloning algorithm appear to be incorrect.
Summary: Steps 14-5 and 17-5 of the DOM 4 Range cloning algorithm appear to be incorrect.
Status: RESOLVED FIXED
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: DOM (show other bugs)
Version: unspecified
Hardware: PC other
: P2 normal
Target Milestone: ---
Assignee: Anne
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-12-03 00:09 UTC by donjjordan
Modified: 2014-12-09 08:34 UTC (History)
2 users (show)

See Also:


Attachments

Description donjjordan 2014-12-03 00:09:45 UTC
Step 14 reads in part:

<snip>
14. Otherwise, if first partially contained child is not null:
    1. Let *clone* be a clone of first partially contained child.
    2. Append *clone* to *fragment*.
    3. Let *subrange* be a new range whose start is....
    4. Let *subfragment* be the result of cloning *subrange*.
    5. Append *subfragment* to *fragment*.
</snip>

And step 17 reads in part:

<snip>
17. Otherwise, if last partially contained child is not null:
    1. Let *clone* be a clone of last partially contained child.
    2. Append *clone* to *fragment*.
    3. Let *subrange* be a new range whose start is....
    4. Let *subfragmen*t be the result of cloning *subrange*.
    5. Append *subfragment* to *fragment*.
</snip>

Shouldn't sub-step 5 in both cases read "Append *subfragment* to *clone*"? The subfragment needs to be appended to the clone created in steps 1 and 2.  Otherwise, the hierarchy of the cloned range is lost.
Comment 1 donjjordan 2014-12-03 00:21:02 UTC
I'm referring specifically to these instructions:

http://w3c.github.io/dom/#concept-range-clone

Following sub-step 5 as written, makes all cloned nodes children of the root DocumentFragment rather than reproducing the tree hierarchy.
Comment 2 Anne 2014-12-06 21:55:11 UTC
Yeah that seems correct. Could you tell me how you'd like to appear in the acknowledgments section?
Comment 3 donjjordan 2014-12-06 22:55:33 UTC
Just use my real name: Don Jordan.  Glad I could be if some assistance.

BTW - I had a couple of questions about some other things in the DOM 4 specification. Is there a good forum or mailing list I can post the questions?  Thanks.
Comment 4 Anne 2014-12-08 10:33:23 UTC
This was also a problem for #concept-range-extract.

https://github.com/whatwg/dom/commit/4b102a2ba6af3b69244b551cc675dabc9fceb93e
Comment 5 donjjordan 2014-12-08 22:17:53 UTC
Yes. I was going to bring that up, but you beat me to it. :) 

I'm in the finishing stages of writing an implementation of the DOM 4 specification, from scratch, in "Modern" C++ for a project at work. All the classes have a full suite of tests for them as well. I've combed over just about every word in your new write-up of the specification. So, basically, I've been idiot testing the document for the past 4 months. I have everything implemented except for the MutationObservers (which I am working on now) and the match method in the Element interface. I have to delve into the CSS selector queries for that. I'm also planning to to make my DOM implementation thread safe.  I've been busy.

The Range class was the only one that I had some difficulty with and I do have a couple of questions regarding it. That's why I asked about a forum or something of the same sort.
Comment 6 Anne 2014-12-09 08:34:51 UTC
Your implementation sounds cool. Sorry about forgetting to answer your question. http://lists.w3.org/Archives/Public/www-dom/ or the WHATWG mailing list.