Skip to content

Conversation

@sirreal
Copy link
Member

@sirreal sirreal commented Nov 12, 2024

This PR builds on (and requires) #7348.

This modifies ::create_fragment( $html, $context ) to use a full processor and create_fragment_at_node instead 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 in create_fragment_at_node instead of in both create_fragment and create_fragment_at_current_node.

This allows for more HTML contexts to be provided to the basic create_fragment where 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 via create_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.

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
@github-actions
Copy link

Test using WordPress Playground

The 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

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@sirreal
Copy link
Member Author

sirreal commented Nov 21, 2024

I've pulled some valuable changes like tests and documentation from #7141 into this PR.

@sirreal sirreal marked this pull request as ready for review November 21, 2024 19:22
@github-actions
Copy link

github-actions bot commented Nov 21, 2024

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 props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props jonsurrell, dmsnell, bernhard-reiter.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@sirreal
Copy link
Member Author

sirreal commented Nov 21, 2024

#7348 has landed. I've merged trunk, added some improvements like tests and _doing_it_wrong from #7141.

I'm opening this up for review now 🎉

@ockham
Copy link
Contributor

ockham commented Nov 25, 2024

The PR says that there are currently conflicts; would you mind rebasing this? 😊

@sirreal
Copy link
Member Author

sirreal commented Nov 25, 2024

Branch is up-to-date and should be conflict free now 👍

@ockham
Copy link
Contributor

ockham commented Nov 27, 2024

Branch is up-to-date and should be conflict free now 👍

Conflicting again now 🙈 Mind rebasing once again? 😅 I'll review today.

Copy link
Contributor

@ockham ockham left a 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 🙂

@sirreal
Copy link
Member Author

sirreal commented Nov 27, 2024

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.

@sirreal
Copy link
Member Author

sirreal commented Nov 27, 2024

I've created and linked ticket https://core.trac.wordpress.org/ticket/62584.

Co-authored-by: Bernie Reiter <[email protected]>
@ockham
Copy link
Contributor

ockham commented Nov 27, 2024

Committed to Core in https://core.trac.wordpress.org/changeset/59467.

@ockham ockham closed this Nov 27, 2024
@sirreal sirreal deleted the html-api/use-create-fragment-at-node-for-main-create-fragment-method branch November 27, 2024 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants