Returns the node name represented by the token.
Description
This matches the DOM API value nodeName
. Some values are static, such as #text
for a text node, while others are dynamically generated from the token itself.
Dynamic names:
- Uppercase tag name for tag matches.
html
for DOCTYPE declarations.
Note that if the Tag Processor is not matched on a token then this function will return null
, either because it hasn’t yet found a token or because it reached the end of the document without matching a token.
Source
*
* @see https://html.spec.whatwg.org/multipage/syntax.html#attributes-2:ascii-case-insensitive
*
* @param string $prefix Prefix of requested attribute names.
* @return array|null List of attribute names, or `null` when no tag opener is matched.
*/
public function get_attribute_names_with_prefix( $prefix ): ?array {
if (
self::STATE_MATCHED_TAG !== $this->parser_state ||
$this->is_closing_tag
) {
return null;
}
$comparable = strtolower( $prefix );
$matches = array();
foreach ( array_keys( $this->attributes ) as $attr_name ) {
if ( str_starts_with( $attr_name, $comparable ) ) {
$matches[] = $attr_name;
}
}
return $matches;
}
/**
Changelog
Version | Description |
---|---|
6.5.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.