Skip to content

Conversation

@sideshowbarker
Copy link
Member

@sideshowbarker sideshowbarker commented Dec 30, 2025

This change brings us into conformance with the “make breaking out of foreign content apply in innerHTML” requirements from the HTML spec PR at whatwg/html#6399 — and into interoperability with current WebKit and Blink behaviour, making fragment parsing break out of foreign content in the same way document parsing does.

Before this code change, when parsing elements like p, div, and nobr inside SVG/MathML via innerHTML, they would stay in the foreign namespace. But, with this change, they now correctly “break out”, and are created in the HTML namespace.

TreeBuilder.java

  • Start tags: Remove fragment-only restriction on break-out behavior
  • End tags: Allow </p> and `
    q to reach mode-handling-in-fragment case
  • Use currentPtr > 0 to preserve context element when popping

Copy link
Member

@hsivonen hsivonen left a comment

Choose a reason for hiding this comment

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

Thank you!

@sideshowbarker sideshowbarker force-pushed the sideshowbarker/fragment-parsing-in-foreign-content branch from 43928ea to 0e04831 Compare December 30, 2025 08:58
This change makes our test harness skip 13 tests for foreign-content
fragment parsing that have been failing from some time now. They’re
not regressions — or not recent regressions at least — so, we can
essentially treat them as “known to fail” for the time being.
@sideshowbarker sideshowbarker force-pushed the sideshowbarker/fragment-parsing-in-foreign-content branch from 0e04831 to 558e032 Compare December 30, 2025 23:09
@sideshowbarker sideshowbarker merged commit 5549e39 into master Dec 30, 2025
12 checks passed
@sideshowbarker sideshowbarker deleted the sideshowbarker/fragment-parsing-in-foreign-content branch December 30, 2025 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants