<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>20445</bug_id>
          
          <creation_ts>2012-12-19 08:24:54 +0000</creation_ts>
          <short_desc>TreeWalker: Specified workflow stuck at root node</short_desc>
          <delta_ts>2012-12-19 20:38:09 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebAppsWG</product>
          <component>DOM</component>
          <version>unspecified</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard>needs test</status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Krinkle">krinklemail</reporter>
          <assigned_to name="Anne">annevk</assigned_to>
          <cc>krinklemail</cc>
    
    <cc>mike</cc>
    
    <cc>Ms2ger</cc>
    
    <cc>www-dom</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>80394</commentid>
    <comment_count>0</comment_count>
    <who name="Krinkle">krinklemail</who>
    <bug_when>2012-12-19 08:24:54 +0000</bug_when>
    <thetext>While taking this API apart to implement in javascript (as exercise to learn how to read specs) I noticed that methods like firstChild() and lastChild() are stuck on the root node when implementing the specification.

For example:
&gt; tw = document.createTreeWalker(document.body, NodeFilter.SHOW_ALL).firstChild()

In Chrome this returns document.body.firstChild.

However when following the spec:

| document.createTreeWalker( Node root, .. )
| * http://dom.spec.whatwg.org/#dom-document-createtreewalker
| &gt; currentNode = root
| TreeWalker::firstChild()
| * http://dom.spec.whatwg.org/#concept-traverse-children
| &gt; node = current = tw.currentNode
| - Filter
| - * http://dom.spec.whatwg.org/#concept-node-filter
| - &gt; node&apos;s nodeType is accepted through NodeFilter.SHOW_ALL
| &gt; tw.currentNode = node; // unaltered
| &gt; return node;

Unless it was intended this way, I appears the spec is missing something in either the Filter or the &quot;Traverse children&quot; subsets to get it off the root.


PS: I&apos;ve looked at all three of these but since I noticed no significant differences in this regard I&apos;ve only linked to the last one above
* http://www.w3.org/TR/2012/WD-dom-20120105/#interface-treewalker
* http://www.w3.org/TR/dom/#interface-treewalker
* http://dom.spec.whatwg.org/#interface-treewalker</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>80398</commentid>
    <comment_count>1</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2012-12-19 12:09:26 +0000</bug_when>
    <thetext>Thanks, should be fixed: https://github.com/whatwg/dom/commit/ff9acf95c68efe5c6fbc718f814da31b4a891a6a

I suspect there may be similar bugs elsewhere in Traversal. I guess I should give it all a second look and rewrite some of it.

How would you like to be listed in the acknowledgments?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>80423</commentid>
    <comment_count>2</comment_count>
    <who name="Krinkle">krinklemail</who>
    <bug_when>2012-12-19 19:59:34 +0000</bug_when>
    <thetext>@Anne: Sure, that&apos;d be splendid!

And thanks for the quick fix. Much appreciated :)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>80424</commentid>
    <comment_count>3</comment_count>
    <who name="Krinkle">krinklemail</who>
    <bug_when>2012-12-19 20:02:03 +0000</bug_when>
    <thetext>For name you may use &quot;Timo Tijhof&quot;.

-- Timo (aka Krinkle)
timotijhof@gmail.com
github.com/Krinkle
about.me/timotijhof</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>