Skip to content

Add innerHTML and outerHTML getters for focus navigation fixtures - #113

Open
cowboyd wants to merge 1 commit into
mainfrom
dom-html-serialization
Open

cowboyd wants to merge 1 commit into
mainfrom
dom-html-serialization

Conversation

@cowboyd

@cowboyd cowboyd commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Some WPT test cases use the outerHTML property to generate the test names. Since we'll need innerHTML and outerHTML eventually, this adds readonly support for them.

Adds Element.innerHTML and Element.outerHTML serialization by using parse5 which is already a development dependency, but moves to be a runtime dependency.

Focus and input tests this supports

  1. Tab and Shift+Tab focus movement around tables: html/interaction/focus/tab-table-caption.html uses outerHTML to build its test names. With the lifecycle and keyboard rungs, all 12 cases across the two caption-side variants now reach their focus-navigation assertions.
  2. Inert selection across HTML, SVG, and MathML: inert/inert-on-non-html.html uses innerHTML.trim() to name 27 cases checking which content remains selectable when inert is applied to HTML or non-HTML elements and their ancestors.
  3. Input-event target ranges during word deletion: the getTargetRanges() returns correct range and cleared after dispatch. case in input-events/input-events-get-target-ranges.html reads innerHTML before and after deletion to check the DOM contents alongside the beforeinput/input target ranges.
  4. Deletion beside noneditable content: editing/other/insert-br-tag-on-text-node-removal-with-non-editable-elements.html uses innerHTML in three cases checking the resulting structure and placeholder <br> insertion after deleting text before, between, or after noneditable children.

Type of change

  • Bug fix
  • Feature
  • Refactor (no behavior change)
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Checklist

  • All tests pass (pnpm test)
  • Files are formatted (pnpm format)
  • I have added/updated tests for my changes (if applicable)
  • I have added a changeset

AI-generated code disclosure

  • This PR includes AI-generated code

@pkg-pr-new

pkg-pr-new Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

commit: f97fb4f

@cowboyd
cowboyd added this pull request to stack #114 November 30, 2026 15:21
@cowboyd
cowboyd marked this pull request as ready for review November 30, 2026 15:50
@cowboyd
cowboyd force-pushed the dom-html-serialization branch from 85257f6 to b111e1c Compare December 1, 2026 18:17
@cowboyd
cowboyd force-pushed the wpt-document-lifecycle branch from 9943043 to 5985ac5 Compare December 1, 2026 18:17
@cowboyd
cowboyd force-pushed the dom-html-serialization branch from b111e1c to ff0de0c Compare December 2, 2026 14:58
@cowboyd
cowboyd force-pushed the wpt-document-lifecycle branch from 7f583c1 to c233ece Compare December 2, 2026 17:26
@cowboyd
cowboyd force-pushed the dom-html-serialization branch from ff0de0c to 129b203 Compare December 2, 2026 17:26
@cowboyd
cowboyd marked this pull request as draft December 2, 2026 22:21
@cowboyd cowboyd added the input focus, keyboard, editing, mouse, anything coming from the release. label Dec 2, 2026
@cowboyd cowboyd added this to the Alpha-1 milestone Dec 2, 2026
@cowboyd
cowboyd removed this pull request from stack #114 December 2, 2026 22:23
@cowboyd
cowboyd force-pushed the wpt-document-lifecycle branch 5 times, most recently from 7bb1c3a to c58e5c2 Compare December 3, 2026 16:44
Base automatically changed from wpt-document-lifecycle to main December 3, 2026 18:45
@cowboyd
cowboyd force-pushed the dom-html-serialization branch from 129b203 to dbc5753 Compare December 3, 2026 19:05
@cowboyd
cowboyd marked this pull request as ready for review December 3, 2026 19:06

@dreyfus92 dreyfus92 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm! just left a question and also @43081j could you give this a second look since you maintain parse5?

Comment thread packages/ui/src/dom.ts
return this.nodeName;
}

get innerHTML(): string {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

with only a getter, el.innerHTML = ... from strict code now throws a generic TypeError, where before it silently set an own prop. vue, solid and preact's dangerouslySetInnerHTML all assign it. is the setter coming soon, or worth a setter that throws a clearer NotSupportedError until then?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, we will need to have them eventually. We are actually already using parse5 in the WPT to parse the html files and build our DOM, so it isn't even that far off.

However, I know that @natemoo-re is also cooking something with html parsing as well, but we could wire it in pretty easily.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

For reference #137

@cowboyd
cowboyd force-pushed the dom-html-serialization branch from dbc5753 to f97fb4f Compare December 4, 2026 03:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

input focus, keyboard, editing, mouse, anything coming from the release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants