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

Pre-existing fetchpriority won't be detected if there are spaces around the equal sign #6325

Closed
vmanthos opened this issue Dec 12, 2023 · 0 comments · Fixed by #6335
Closed
Assignees
Labels
lcp type: bug Indicates an unexpected problem or unintended behavior
Milestone

Comments

@vmanthos
Copy link
Contributor

Before submitting an issue please check that you’ve completed the following steps:

  • Made sure you’re on the latest version ✔️
  • Used the search feature to ensure that the bug hasn’t been reported before ✔️

Describe the bug

We won't be adding the fetchpriority property if one already exists:

if ( preg_match( '/fetchpriority=[\'"]([^\'"]+)[\'"]/', $matches[0] ) ) {

However, if it's added with spaces before of after the = sign like so:

<img src="https://example.com/dummy.png" fetchpriority = "high">

we will not detect it and add our own on top of it.

See the current RegEx in action: https://regex101.com/r/cqHgtE/1

To Reproduce
Steps to reproduce the behavior:

  1. Add an LCP image to a page using the example code provided earlier.
  2. After LCP has been processed by the SaaS, check the source code of the page.
  3. Duplicate entries of the fetchpriority property will be there.

Expected behavior

The fetchpriority property should be correctly detected even if there are spaces before/after the = sign.

Screenshots

N/A

Additional context

N/A

Acceptance Criteria (for WP Media team use only)
Clear instructions for developers, to be added before the grooming

@jeawhanlee jeawhanlee added type: bug Indicates an unexpected problem or unintended behavior lcp labels Dec 12, 2023
@jeawhanlee jeawhanlee added this to the 3.16 milestone Dec 12, 2023
@Tabrisrp Tabrisrp self-assigned this Dec 15, 2023
Tabrisrp added a commit that referenced this issue Jan 2, 2024
…d equal sign (#6335)

Co-authored-by: Michael Lee <michaelleemichaellee408@gmail.com>
@Tabrisrp Tabrisrp closed this as completed Jan 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lcp type: bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants