Skip to content

Further Attr node fixes for compareDocumentPosition() #312

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 31, 2016

Conversation

annevk
Copy link
Member

@annevk annevk commented Aug 23, 2016

This algorithm is impossible. Hopefully fixes #309.

@annevk
Copy link
Member Author

annevk commented Aug 24, 2016

(Please don't merge, just review.)


<ol>
<li>
<p>For each <a>attribute</a> <var>node2Attribute</var> in <var>attr2</var>'s
<a for=Attr>element</a>'s <a for=Element>attribute list</a>:
<p>For each <a>attribute</a> <var>node2Attr</var> in <var>node2</var>'s
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Segfault, here it's possible for node1 and node2 to both be null while attr1 is non-null. I think the check needs to be "If node1 and attr1 are non-null and node1 is node2" or similar, i.e. add a null-check for node2.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reading this anew, I also wonder if it'd be more clear to call node2Attr simply attr or something without a 2 in it, since node1==node2 here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call.

@annevk annevk force-pushed the comparedocumentposition branch from fa39e5c to 675f7c1 Compare August 30, 2016 10:40
</ol>
<li>
<p>If <var>node1</var>’s <a data-link-type="dfn" href="#concept-tree-root">root</a> is not <var>node2</var>’s <a data-link-type="dfn" href="#concept-tree-root">root</a> or <var>node1</var> and <var>node2</var> are <a data-link-type="dfn" href="#concept-attribute">attributes</a>, then return the result of adding <code class="idl"><a data-link-type="idl" href="#dom-node-document_position_disconnected">DOCUMENT_POSITION_DISCONNECTED</a></code>, <code class="idl"><a data-link-type="idl" href="#dom-node-document_position_implementation_specific">DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC</a></code>, and
<p>If <var>node1</var> or <var>node2</var> is null, or <var>node1</var>’s <a data-link-type="dfn" href="#concept-tree-root">root</a> is
not <var>node2</var>’s <a data-link-type="dfn" href="#concept-tree-root">root</a>, then return the result of adding <code class="idl"><a data-link-type="idl" href="#dom-node-document_position_disconnected">DOCUMENT_POSITION_DISCONNECTED</a></code>, <code class="idl"><a data-link-type="idl" href="#dom-node-document_position_implementation_specific">DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC</a></code>, and
either <code class="idl"><a data-link-type="idl" href="#dom-node-document_position_preceding">DOCUMENT_POSITION_PRECEDING</a></code> or <code class="idl"><a data-link-type="idl" href="#dom-node-document_position_following">DOCUMENT_POSITION_FOLLOWING</a></code>, with the
constraint that this is to be consistent, together. </p>
<p class="note no-backref" role="note">Whether to return <code class="idl"><a data-link-type="idl" href="#dom-node-document_position_preceding">DOCUMENT_POSITION_PRECEDING</a></code> or <code class="idl"><a data-link-type="idl" href="#dom-node-document_position_following">DOCUMENT_POSITION_FOLLOWING</a></code> is typically implemented via pointer comparison. In
JavaScript implementations a cached <code class="lang-javascript highlight"><span class="nb">Math</span><span class="p">.</span><span class="nx">random</span><span class="p">()</span> </code> value can
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a Bikeshed bug on this line, an extra space before </code> that you can see in the rendered result. @tabatkins, known issue?

@foolip
Copy link
Member

foolip commented Aug 30, 2016

OK, finished reviewing, including fixes up to "node2attr -> attr". Things that are impossible just take longer.

@annevk
Copy link
Member Author

annevk commented Aug 30, 2016

I think I fixed the last two non-bikeshed issues.

@tabatkins
Copy link
Contributor

Looking into the Bikeshed issue.

adding {{Node/DOCUMENT_POSITION_CONTAINS}} to {{Node/DOCUMENT_POSITION_PRECEDING}}.

<li><p>If <var>node1</var> is a <a>descendant</a> of <var>node2</var>, then return the result of
<li><p>If <var>node1</var> is a <a>descendant</a> of <var>node2</var> and <var>attr1</var> is null,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, this one needs to say "and attr2 is null"

@foolip
Copy link
Member

foolip commented Aug 31, 2016

Reviewed "review comments", found a typo, but otherwise this now looks great, I like the added note!

@annevk annevk force-pushed the comparedocumentposition branch from d90bb5f to 3f10adf Compare August 31, 2016 16:27
@annevk annevk merged commit 0e17e05 into master Aug 31, 2016
@annevk annevk deleted the comparedocumentposition branch August 31, 2016 16:29
@tabatkins
Copy link
Contributor

And should be fixed.

@foolip
Copy link
Member

foolip commented Sep 2, 2016

Thanks Tab!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

compareDocumentPosition with Attr nodes still not quite right
3 participants