-
Notifications
You must be signed in to change notification settings - Fork 3.1k
HTML API: Use create_fragment_at_node to allow more contexts in create_fragment #7777
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
HTML API: Use create_fragment_at_node to allow more contexts in create_fragment #7777
Conversation
This reverts commit ba9e218.
null should not be returned in this case, but it is part of the signature and should be covered here.
…i/use-create-fragment-at-node-for-main-create-fragment-method
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Inspired by WordPress#7141 Co-authored-by: Dennis Snell <[email protected]>
Inspired by WordPress#7141 Co-authored-by: Dennis Snell <[email protected]>
|
I've pulled some valuable changes like tests and documentation from #7141 into this PR. |
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
The PR says that there are currently conflicts; would you mind rebasing this? 😊 |
…in-create-fragment-method
|
Branch is up-to-date and should be conflict free now 👍 |
Conflicting again now 🙈 Mind rebasing once again? 😅 I'll review today. |
…in-create-fragment-method
…in-create-fragment-method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you 👍
I love how this re-organizes the code in create_fragment and create_fragment_at_current_node.
I'll commit this once CI is green. Do you want to open a separate ticket for this? Otherwise, I can do a "See #62357" (instead of a "Fixes #..."). It might be a big enough change to warrant a ticket of its own though 🙂
|
I'll create a dedicated ticket for this. It's a very logical step after #7348, but does introduce a new feature and is a significant refactor. |
|
I've created and linked ticket https://core.trac.wordpress.org/ticket/62584. |
tests/phpunit/tests/html-api/wpHtmlProcessorFragmentParsing.php
Outdated
Show resolved
Hide resolved
tests/phpunit/tests/html-api/wpHtmlProcessorFragmentParsing.php
Outdated
Show resolved
Hide resolved
tests/phpunit/tests/html-api/wpHtmlProcessorFragmentParsing.php
Outdated
Show resolved
Hide resolved
Co-authored-by: Bernie Reiter <[email protected]>
|
Committed to Core in https://core.trac.wordpress.org/changeset/59467. |
✅
This PR builds on (and requires) #7348.This modifies
::create_fragment( $html, $context )to use a full processor andcreate_fragment_at_nodeinstead of the other way around. This makes more sense and makes the main factory methods more clear, where the state required for fragments is set up increate_fragment_at_nodeinstead of in bothcreate_fragmentandcreate_fragment_at_current_node.This allows for more HTML contexts to be provided to the basic
create_fragmentwhere the provided context HTML is appended to<!DOCTYPE html>, a full processor is created, the last tag opener is found, and a fragment parser is created at that node viacreate_fragment_at_current_node.The HTML5lib tests are updated accordingly to use this new method to create fragments.
Trac ticket: https://core.trac.wordpress.org/ticket/62584
(previously https://core.trac.wordpress.org/ticket/62357)
Closes #7141.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.