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

Should setting outerHTML on child of DocumentFragment throw an Error? #8657

Closed
josepharhar opened this issue Dec 29, 2022 · 2 comments
Closed

Comments

@josepharhar
Copy link
Contributor

Blink and WebKit bugs were opened about this recently:

Blink and WebKit both throw errors, and Gecko does not.
According to the reporter, the spec says that no error should be thrown but I haven't looked at the spec myself yet.
Any thoughts on which behavior we should converge on?
I see in the WebKit bug that @cdumez worked on this recently. Any thoughts?

const fragment = new DocumentFragment();
fragment.appendChild(document.createElement('div'));
fragment.firstChild.outerHTML = '';
@smaug----
Copy link

smaug---- commented Dec 29, 2022

outerHTML is defined in https://w3c.github.io/DOM-Parsing/#dom-element-outerhtml not in HTML spec.

And yes, setting it should not throw, in case the context object doesn't have a parent, or if parent is document fragment.

@josepharhar
Copy link
Contributor Author

thanks, ill update blink accordingly

webkit-commit-queue pushed a commit to Ahmad-S792/WebKit that referenced this issue Jul 15, 2023
https://bugs.webkit.org/show_bug.cgi?id=249737
rdar://problem/103746193

Reviewed by Chris Dumez.

This patch aligns WebKit with Gecko / Firefox and Web-Spec [1].

In 238774@main, WebKit aligned with behavior for better compatibility but
it was not correct and clarified later to not throw error [2]. This PR is
essentially revert part of 238774@main with update to align by not throwing error.

[1] https://w3c.github.io/DOM-Parsing/#dom-element-outerhtml
[2] whatwg/html#8657

* Source/WebCore/dom/Element.cpp:
(Element::setOuterHTML): Update to not throw error
* LayoutTests/fast/dynamic/outerHTML-no-element.html: Rebaselined
* LayoutTests/fast/dynamic/outerHTML-no-element-expected.txt: Rebaselined
* LayoutTests/fast/dom/set-outer-html-special-cases.html: Rebaselined
* LayoutTests/fast/dom/set-outer-html-special-cases-expected.txt: Rebaselined

Canonical link: https://commits.webkit.org/266086@main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants