Skip to content

Add $outerHTML property to DOM #15887

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

Closed
wants to merge 3 commits into from
Closed

Conversation

nielsdos
Copy link
Member

No description provided.

Copy link
Member

@kocsismate kocsismate left a comment

Choose a reason for hiding this comment

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

LGTM apart from two nits, but I'm not knowledgable enough to actually approve it. I guess feel free to merge it.

@nielsdos
Copy link
Member Author

The documentation cannot be found here. It was moved to https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#fragment-serializing-algorithm-steps

The joys of a living specification ;)

Thanks for the review! I'll write the mailing list soon-ish to see if anyone objects and if I hear no complaints merge it.

@nielsdos nielsdos changed the title [not 8.4] Add $outerHTML property to DOM Add $outerHTML property to DOM Sep 28, 2024
Copy link
Contributor

@dmsnell dmsnell left a comment

Choose a reason for hiding this comment

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

It's interesting seeing the tests call saveXML() instead of saveHTML().

Did you consider adding a test showing a situation where the DOM is unrepresentable?

$dom = DOM\HTMLDocument::createFromString( '<a href="#one"><p>Link</p></a>' );
$p = $dom->body->querySelector('p');
$p->outerHTML = '<a href="#two">Another Link</a>';
echo $dom->saveHTML();

// <html><head></head><body><a href="#one"><a href="#two">Another Link</a></a></body></html>

I don't know if this is worthwhile, but it could clarify that it's following the spec and producing an invalid document.

@nielsdos
Copy link
Member Author

@dmsnell Thanks for the input. In the end calling saveXML or saveHTML don't really matter that much. I'll add calls for saveHTML too. The more testing the better anyway. For the same reason I'll add your test as well.

@nielsdos nielsdos closed this in 39ae00f Oct 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants