Skip to content
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

Implement missing "insert a foreign element" parsing algorithm #22695

Open
jdm opened this issue Jan 15, 2019 · 5 comments
Open

Implement missing "insert a foreign element" parsing algorithm #22695

jdm opened this issue Jan 15, 2019 · 5 comments

Comments

@jdm
Copy link
Member

@jdm jdm commented Jan 15, 2019

@jdm jdm added the I-spec-update label Jan 15, 2019
@AnshulMalik
Copy link
Contributor

@AnshulMalik AnshulMalik commented Jan 19, 2019

@jdm Can you provide some more context here please?

@jdm
Copy link
Member Author

@jdm jdm commented Jan 21, 2019

It took me a while to read and understand what it was about, but the fundamental change is this commit. From reading Servo's html5 parser implementation, it looks like it's modifying an algorithm that has changed since we originally implemented it. I think I see a few important steps here - currently, the html5ever parser implements the "create an element for the token" algorithm here (spec), but we're missing the "insert a foreign element" algorithm that the HTML specification PR changed (https://html.spec.whatwg.org/multipage/parsing.html#insert-a-foreign-element). We should:

  • modify html5ever's insert_element function to implement the "insert a foreign element" algorithm (which invokes the "create an element for the token", which we can mostly reuse)
  • add push_new_element_queue and pop_current_element_queue methods to the TreeSink trait (here)
  • implement these new methods in Servo's parser implementation, checking self.parsing_algorithm and calling the appropriate ScriptThread methods (push_new_element_queue and pop_current_element_queue)

I believe those changes should allow us to pass some tests that are currently failing.

@jdm jdm changed the title Add parser phases Implement missing "insert a foreign element" parsing algorithm Jan 21, 2019
@jdm
Copy link
Member Author

@jdm jdm commented Jan 21, 2019

The test to run would be ./mach test-wpt tests/wpt/web-platform-tests/custom-elements/connected-callbacks-html-fragment-parsing.html.

@jdm
Copy link
Member Author

@jdm jdm commented Jan 21, 2019

And Servo's parser implementation lives in components/script/dom/servoparser/mod.rs.

@AnshulMalik
Copy link
Contributor

@AnshulMalik AnshulMalik commented Jan 22, 2019

Thanks @jdm so much. I'll take a stab at it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.