Skip to content

Add Dom\Element::insertAdjacentHTML() #16614

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

Merged
merged 1 commit into from
Nov 9, 2024

Conversation

nielsdos
Copy link
Member

@nielsdos nielsdos commented Oct 26, 2024

Blocked by whatwg/html#10725

@nielsdos nielsdos force-pushed the dom-insert-adjacent-html branch 2 times, most recently from 8417dfd to e028a00 Compare October 28, 2024 18:22
@nielsdos nielsdos marked this pull request as ready for review October 28, 2024 18:22
@nielsdos nielsdos requested a review from kocsismate as a code owner October 28, 2024 18:22
@nielsdos
Copy link
Member Author

According to the WHATWG issue, there's indeed a spec mistake. So the implementation here is correct after all.

Copy link
Member

@arnaud-lb arnaud-lb left a comment

Choose a reason for hiding this comment

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

The code and algorithm look right to me

xmlNodePtr context = NULL;

/* 3. Use the first matching item from this list: (...) */
switch (ZSTR_LEN(where) + ZSTR_VAL(where)[2]) {
Copy link
Contributor

@divinity76 divinity76 Nov 1, 2024

Choose a reason for hiding this comment

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

wtf
(edit: yes i see it, avoid strcmp for performance~)

Copy link
Member Author

Choose a reason for hiding this comment

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

Similar trick is done in ext/random btw if you're curious

Copy link
Member

Choose a reason for hiding this comment

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

We really need a mechanism to solve this in a generic fashion. The RoundingMode enum uses the same trick.

Copy link
Member

Choose a reason for hiding this comment

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

Agreed. It would be useful to be able to compare enum elements, or at least their name, by address.

Maybe we can store the address of enum elements in some struct once they are instantiated. Storing them in the zend_class_entry would be ideal, but I'm not sure this is doable. Case classes may help with that. Alternatively we could store them in a separate struct generated in _arginfo.h.

@divinity76
Copy link
Contributor

divinity76 commented Nov 1, 2024

LGTM 👍

@nielsdos nielsdos force-pushed the dom-insert-adjacent-html branch from e028a00 to 64083ff Compare November 4, 2024 19:10
@nielsdos
Copy link
Member Author

nielsdos commented Nov 9, 2024

No complaints were raised on the mailing list, I'm merging this.

@nielsdos nielsdos merged commit a3b27c0 into php:master Nov 9, 2024
10 checks passed
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.

4 participants