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

RichText: Reuse document in createElement #12470

Closed
wants to merge 1 commit into from

Conversation

ellatrix
Copy link
Member

Description

This one is similar to #12402: we should reuse the same document in createElement calls. I wonder if we can use the same function in both places. Note that I had to move the old function to the test as it needs to be able to have two references.

Cc @aduth.

How has this been tested?

Screenshots

Types of changes

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.

@aduth
Copy link
Member

aduth commented Nov 30, 2018

Note that I had to move the old function to the test as it needs to be able to have two references.

This is maybe a bit concerning in how we've already encountered legitimate need for holding the reference? I suppose this is all still internal to rich-text

Could the test maybe be updated to .cloneNode the value returned for each? It would be preferable if the test weren't running a custom reimplementation.

@aduth
Copy link
Member

aduth commented Nov 30, 2018

I wonder if we can use the same function in both places.

Would it be as simple as changing createEmpty (to-dom.js) to:

const createEmpty = () => createElement( document, '' );

?

@ellatrix
Copy link
Member Author

Let's work on your PR.

@ellatrix ellatrix closed this Nov 30, 2018
@ellatrix ellatrix deleted the try/rich-text-reuse-doc-create-element branch November 30, 2018 16:00
@ellatrix
Copy link
Member Author

This is maybe a bit concerning in how we've already encountered legitimate need for holding the reference? I suppose this is all still internal to rich-text

Yeah, I think it's fine. It's all internal.

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.

2 participants