Returns if a matched tag contains the given ASCII case-insensitive class name.
Parameters
$wanted_classstringrequired- Look for this CSS class name, ASCII case-insensitive.
Source
public function has_class( $wanted_class ): ?bool {
if ( self::STATE_MATCHED_TAG !== $this->parser_state ) {
return null;
}
$case_insensitive = self::QUIRKS_MODE === $this->compat_mode;
$wanted_length = strlen( $wanted_class );
foreach ( $this->class_list() as $class_name ) {
if (
strlen( $class_name ) === $wanted_length &&
0 === substr_compare( $class_name, $wanted_class, 0, strlen( $wanted_class ), $case_insensitive )
) {
return true;
}
}
return false;
}
Changelog
| Version | Description |
|---|---|
| 6.4.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.