[wp-trac] [WordPress Trac] #61531: HTML API: Audit class name methods for consistency and correctness

WordPress Trac noreply at wordpress.org
Wed Sep 4 04:32:52 UTC 2024


#61531: HTML API: Audit class name methods for consistency and correctness
--------------------------------------+-----------------------------
 Reporter:  jonsurrell                |       Owner:  (none)
     Type:  enhancement               |      Status:  assigned
 Priority:  normal                    |   Milestone:  Future Release
Component:  HTML API                  |     Version:  6.5
 Severity:  normal                    |  Resolution:
 Keywords:  has-patch has-unit-tests  |     Focuses:
--------------------------------------+-----------------------------

Comment (by dmsnell):

 In [changeset:"58985" 58985]:
 {{{
 #!CommitTicketReference repository="" revision="58985"
 HTML API: Respect document compat mode when handling CSS class names.

 The HTML API has been behaving as if CSS class name selectors matched
 class names in an ASCII case-insensitive manner. This is only true if the
 document in question is set to quirks mode. Unfortunately most documents
 processed will be set to no-quirks mode, meaning that some CSS behaviors
 have been matching incorrectly when provided with case variants of class
 names.

 In this patch, the CSS methods have been audited and updated to adhere to
 the rules governing ASCII case sensitivity when matching classes. This
 includes `add_class()`, `remove_class()`, `has_class()`, and
 `class_list()`. Now, it is assumed that a document is in no-quirks mode
 unless a full HTML parser infers quirks mode, and these methods will treat
 class names in a byte-for-byte manner. Otherwise, when a document is in
 quirks mode, the methods will compare the provided class names against
 existing class names for the tag in an ASCII case insensitive way, while
 `class_list()` will return a lower-cased version of the existing class
 names.

 The lower-casing in `class_list()` is performed for consistency, since
 it's possible that multiple case variants of the same comparable class
 name exists on a tag in the input HTML.

 Developed in https://github.com/WordPress/wordpress-develop/pull/7169
 Discussed in https://core.trac.wordpress.org/ticket/61531

 Props dmsnell, jonsurrell.
 See #61531.
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/61531#comment:21>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list