Make WordPress Core

Opened 17 months ago

Closed 17 months ago

Last modified 17 months ago

#56675 closed defect (bug) (fixed)

Extra spaces appear in css queue

Reported by: elten's profile elten Owned by: audrasjb's profile audrasjb
Milestone: 6.1 Priority: normal
Severity: minor Version:
Component: Script Loader Keywords: has-patch has-unit-tests commit
Focuses: coding-standards Cc:

Description

In the css queue, there are two spaces between “id” and “href”, also have this problem in wordpress.org.

<link rel='stylesheet' id='wporg-global-fonts-css'  href='https://wordpress.org/wp-content/mu-plugins/pub-sync/global-fonts/style.css?ver=1663691227' media='all' />
<link rel='stylesheet' id='wporg-parent-2021-style-css'  href='https://wordpress.org/wp-content/themes/wporg-parent-2021/build/style.css?ver=1660938306' media='all' />
<link rel='stylesheet' id='wporg-main-2022-style-css'  href='https://wordpress.org/wp-content/themes/wporg-main-2022/build/style/style-index.css?ver=1663690308' media='all' />
<link rel='stylesheet' id='wporg-parent-block-styles-css'  href='https://wordpress.org/wp-content/themes/wporg-parent-2021/build/block-styles.css?ver=1661271656' media='all' />
<link rel='stylesheet' id='wporg-global-header-footer-css'  href='https://wordpress.org/wp-content/mu-plugins/pub-sync/blocks/global-header-footer/build/style.css?ver=1664222912' media='all' />

https://i.postimg.cc/6QJP1Ypp/wp.png

==========

WordPress version : 6.0.2
Appears after loading the css queue ( use wp_enqueue_style() ) .
The problem has nothing to do with templates.

Attachments (1)

56675-title.png (22.8 KB) - added by whaze 17 months ago.
link tag with and without title attr

Download all attachments as: .zip

Change History (10)

#1 @audrasjb
17 months ago

  • Keywords needs-patch added

Hello, welcome to WordPress Core Trac and thank you for opening this ticket!

The issue comes from this line. When the third %s placeholder is empty, two spaces are printed.

This ticket was mentioned in PR #3354 on WordPress/wordpress-develop by whaze.


17 months ago
#2

  • Keywords has-patch added; needs-patch removed

#3 @whaze
17 months ago

hello,
i submitted a PR : moving the space in the $title var to prevent double space beetween id and href attribute, so the space is still ok when link tag have a title attr

https://postimg.cc/sBdSS4JW

@whaze
17 months ago

link tag with and without title attr

#4 @audrasjb
17 months ago

  • Keywords changes-requested added

Looks great to me.
By the way, we should also update the related unit tests located in tests/phpunit/tests/dependencies/styles.php @whaze

#5 @whaze
17 months ago

@audrasjb
i updated the unit tests

#6 @audrasjb
17 months ago

  • Keywords has-unit-tests commit added; changes-requested removed
  • Milestone changed from Awaiting Review to 6.1
  • Version 6.0.2 deleted

Thanks @whaze, looks great.
Also, thanks @SergeyBiryukov for adding RTL support and for the few small enhancements ✌️

Let's ship this with 6.1.

#7 @audrasjb
17 months ago

  • Component changed from Formatting to Script Loader

#8 @audrasjb
17 months ago

  • Owner set to audrasjb
  • Resolution set to fixed
  • Status changed from new to closed

In 54348:

Script Loader: Prevent double space between attributes in WP_Styles class.

This changeset prevents <link /> elements to display a double space between attributes when no title attribute is provided.

Props elten, audrasjb, whaze, SergeyBiryukov.
Fixes #56675.

Note: See TracTickets for help on using tickets.