-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
DOM "insertion steps" #2771
Comments
@annevk Your thoughts, as DOM editor? |
I do think that makes sense. We just haven't gone down that rabbit hole yet due to the amount of effort required and not everything being set up as clear from the beginning. |
I'll tag this as "good first bug", although it's on the more difficult side. Explicitly, what you'd want to do is:
People can feel free to work on individual instances here, or e.g. do the ones that look easy and ask questions about the harder ones. |
I guess ideally we'd also do this for "node A is removed", "node is inserted into a document", "node is removed from a document", "becomes connected", and "becomes disconnected". Hmm. Now I am not as sure this is worthwhile; maybe it would just obscure things. |
Hi, I am a newbie and I've finished a course on html and it's been a week. As this is a "good first issue" I would like to try resolve this. It would be great if someone can just give me a basic introduction on what to do. |
Hi, I am thinking of contributing to this issue. I would like some confirmation/clarification before I actually send my patch in. As far as I understand, this issue's goal is to rewrite every instance of "is inserted into" with specific insertion steps, is that correct?
and changing the wording to something like:
If this is the way to go, I will start with the more trivial ones, then go on to trying the less obvious ones afterwards. Thank you! |
Hmm. I think you are on the right track given how the issue is described. But, I'm revisiting this issue five years later, and I'm no longer sure it's a good idea. My understanding of how DOM works is that it says specifications may define insertion steps, which take insertedNode. So basically it expects one set of "insertion steps" for all of the HTML Standard, which contains a lot of if statements. Something like:
This seems kind of bad!! An alternate way of doing it would be for HTML to define many insertion steps. Something like:
and then do that for every element. But my take is that HTML is already defining a single set of insertion steps, just in a distributed fashion. And it's doing so pretty rigorously already. Look at the definition of "a node is inserted":
I take this as basically synonymous with:
so I think the current specification is already pretty good! @annevk, what do you think? @sylph01, sorry if this ends up resulting in some wasted time of yours investigating! |
No problem! If anything needs to be changed here, I might suggest that writing out "Run any steps that this standard marks as taking place when insertedNode [is inserted into] parent" explicitly would clarify what "insertion steps" mean in HTML Standard's context and also tells the reader that "insertion steps" are defined at each element in a distributed fashion.
|
I haven't checked if this is a problem in practice, but a theoretical problem here is the lack of defined ordering. That's also a problem with the extension point. That usually argues for a single algorithm or a more coordinated approach. |
@annevk and I discussed this a bit more in chat and we think the best path forward is to do something similar to what the current spec is doing, but more rigorous and well-grounded. This is similar to my previous comment but with a different style. So I think the plan would be something like the following:
Does that make sense? If so, please feel free to start on a pull request, probably with just one or two replacements for now since setting up the initial definition infrastructure will be the hardest part that we want to review early. |
Yes, I think this approach makes sense. From reading the current wording, I will first prepare a pull request that does the following:
I also noticed that this might need a follow-up where the same thing would be done for [removing steps] and [children changed steps] if they have specific instances in the HTML Standard. I will try to finish the insertion steps first, but if there's a need for this change, I might do it in the same PR as well. |
Created a work-in-progress PR at #7712. This PR currently has the fixes mentioned above. |
#7712 is almost ready. However it turns out it is just the first step as there are a number of dependent definitions. Here is a checklist:
We should do those in separate PRs. I think the foundation of #7712 will make this much easier, as we can extend the HTML Standard insertion steps to call out to various algorithms. However there are some tricky subtleties that make it probably not a good-first-issue anymore, such as:
Anyway, @sylph01 or any other contributor is welcome to continue working on this project after #7712. But I also want to acknowledge that that will be a good intermediate stopping point, and the work will get trickier after that. |
Part of #2771. This removes the concepts of "node is inserted" and "node is removed" in favor of explicit HTML Standard insertion/removing steps, which are of the form the DOM Standard wants us to use. These HTML Standard insertion/removing steps, in turn, call out to element definition-specific "HTML element insertion/removing steps". This does not complete #2771, as there remain several less-rigorous definitions, outlined in #2771 (comment). But it gives us the right scaffolding and prevents any further usage of the node is inserted/removed definitions.
Part of whatwg#2771. This removes the concepts of "node is inserted" and "node is removed" in favor of explicit HTML Standard insertion/removing steps, which are of the form the DOM Standard wants us to use. These HTML Standard insertion/removing steps, in turn, call out to element definition-specific "HTML element insertion/removing steps". This does not complete whatwg#2771, as there remain several less-rigorous definitions, outlined in whatwg#2771 (comment). But it gives us the right scaffolding and prevents any further usage of the node is inserted/removed definitions.
This comment was marked as off-topic.
This comment was marked as off-topic.
Moving to #10331. |
https://html.spec.whatwg.org/#dom-trees
Per https://dom.spec.whatwg.org/#concept-node-insert-ext , "insertion steps" are supposed to be algorithms, but the HTML spec does not define any explicit insertion steps algorithm(s).
It just says "A <conceptual event> [occurs] when the insertion steps are invoked with <conditions>" a few times, with which set of insertion steps "the insertion steps" refers to being unclear.
I would instead expect something more like:
The text was updated successfully, but these errors were encountered: