File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4645,13 +4645,38 @@ public function remove_class( $class_name ): bool {
46454645 /**
46464646 * Returns if a matched tag contains the given ASCII case-insensitive class name.
46474647 *
4648+ *
4649+ * > When matching against a document which is in quirks mode, class names must be matched
4650+ * > ASCII case-insensitively; class selectors are otherwise case-sensitive, only matching
4651+ * > class names they are identical to.
4652+ *
4653+ * @see https://www.w3.org/TR/selectors-4/#class-html
4654+ *
46484655 * @since 6.6.0 Subclassed for the HTML Processor.
4656+ * @since 6.7.0 Matches are case sensitive in no-quirks mode (the default).
46494657 *
46504658 * @param string $wanted_class Look for this CSS class name, ASCII case-insensitive.
46514659 * @return bool|null Whether the matched tag contains the given class name, or null if not matched.
46524660 */
46534661 public function has_class ( $ wanted_class ): ?bool {
4654- return $ this ->is_virtual () ? null : parent ::has_class ( $ wanted_class );
4662+ if ( $ this ->is_virtual () ) {
4663+ return false ;
4664+ }
4665+
4666+ if ( self ::STATE_MATCHED_TAG !== $ this ->parser_state ) {
4667+ return null ;
4668+ }
4669+
4670+ $ compare_func = WP_HTML_Processor_State::QUIRKS_MODE === $ this ->state ->compat_mode ?
4671+ 'strcasecmp ' :
4672+ 'strcmp ' ;
4673+
4674+ foreach ( $ this ->class_list () as $ class_name ) {
4675+ if ( 0 === $ compare_func ( $ class_name , $ wanted_class ) ) {
4676+ return true ;
4677+ }
4678+ }
4679+ return false ;
46554680 }
46564681
46574682 /**
You can’t perform that action at this time.
0 commit comments