diff --git a/src/wp-includes/html-api/class-wp-html-tag-processor.php b/src/wp-includes/html-api/class-wp-html-tag-processor.php index cd5814f0a4ad3..910ad74a7d74a 100644 --- a/src/wp-includes/html-api/class-wp-html-tag-processor.php +++ b/src/wp-includes/html-api/class-wp-html-tag-processor.php @@ -1207,21 +1207,11 @@ public function class_list() { $is_quirks = self::QUIRKS_MODE === $this->compat_mode; - $at = 0; + $at = strspn( $class, " \t\f\r\n" ); while ( $at < strlen( $class ) ) { - // Skip past any initial boundary characters. - $at += strspn( $class, " \t\f\r\n", $at ); - if ( $at >= strlen( $class ) ) { - return; - } - // Find the byte length until the next boundary. $length = strcspn( $class, " \t\f\r\n", $at ); - if ( 0 === $length ) { - return; - } - - $name = substr( $class, $at, $length ); + $name = substr( $class, $at, $length ); if ( $is_quirks ) { $name = strtolower( $name ); } @@ -1232,12 +1222,12 @@ public function class_list() { * Given this, it is probably faster overall to scan an array for a value rather * than to use the class name as a key and check if it's a key of $seen. */ - if ( in_array( $name, $seen, true ) ) { - continue; + if ( ! in_array( $name, $seen, true ) ) { + $seen[] = $name; + yield $name; } - $seen[] = $name; - yield $name; + $at += strspn( $class, " \t\f\r\n", $at ); } }