-
Notifications
You must be signed in to change notification settings - Fork 3.1k
selectedcontent post-connection steps did not break out of the loop #11878
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
Conversation
source
Outdated
| <code>selectedcontent</code> element, then set <var>selectedcontent</var>'s <span | ||
| data-x="selectedcontent-disabled">disabled</span> state to true.</p></li> | ||
| data-x="selectedcontent-disabled">disabled</span> state to true and | ||
| <span>break</span>.</p></li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm understanding things correctly, I think there's an undesirable side-effect of this break. (I got here from reviewing @josepharhar's CL that implements this behavior.)
In particular (and hopefully I'm rememembering how all this stuff works correctly, since I'm not checking all the pieces with the spec as I go along), if we start with:
<select id="s">
<button>
<selectedcontent></selectedcontent>
</button>
<option selected>One</option>
</select>then the <selectedcontent> will initially be filled with "One".
Now, suppose that JS comes along and does:
const sc = document.createElement("selectedcontent");
const o = document.createElement("option");
o.append(sc);
document.getElementById("s").prepend(o);At this point, I think we're going to:
- invoke these post-connection steps being modified in this PR
- break at this
breakstatement - Because of that break, leave the existing
<selectedcontent>element with the "One" contents inside of it.
However, after this change, the "get a select's enabled selectedcontent" algorithm will now return null, because the <selectedcontent> added by the JS above is disabled. This means that as a result of this break, we'll be leaving the previously-working <selectedcontent> element with stale content, permanently. That seems pretty weird to me (though I admit that every case where a <selectedcontent> is disabled is effectively an error case).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That said, now that I understand @josepharhar's comment on the rationale here, maybe we do need to break if we hit an ancestor selectedcontent, because otherwise the algorithm will go into an infinite loop. So maybe we want to change this so this particular break is only when the ancestor is a selectedcontent element?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So maybe we want to change this so this particular break is only when the ancestor is a selectedcontent element?
I tried implementing this, but it still encountered an infinite loop in one of the test cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@josepharhar maybe you can propose how you want to address this? Because as-is there's clearly issues too. At least I couldn't implement the specification text in WebKit...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should address this by leaving the case that David described broken. This is what it looks like after running the script:
<select>
<option>
<selectedcontent></selectedcontent>
</option>
<button>
<selectedcontent></selectedcontent>
</button>
<option selected>one</option>
</select>I don't know why anyone would want to put a second selectedcontent in an option like this. If we leave it "broken" by not updating any of the selectedcontent elements, I think that's fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I've now made the PR reflect what you wanted and also fixed a couple other nits. I haven't yet checked your tests. Can you review again? And maybe David too if he has the time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, the current state of this PR matches the logic in my chromium patch. I asked David to check again as well.
And also has an unused ancestor variable.
81b1309 to
94faffd
Compare
|
I added another change here to also early return for disabled |
And also has an unused ancestor variable.
/form-elements.html ( diff )