Skip to content

Commit 156a31e

Browse files
committed
Fix set_bookmark
1 parent e83ff85 commit 156a31e

1 file changed

Lines changed: 18 additions & 5 deletions

File tree

src/wp-includes/html-api/class-wp-html-tag-processor.php

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,10 +1158,7 @@ public function has_class( $wanted_class ) {
11581158
*/
11591159
public function set_bookmark( $name ) {
11601160
// It only makes sense to set a bookmark if the parser has paused on a concrete token.
1161-
if (
1162-
self::STATE_COMPLETE === $this->parser_state ||
1163-
self::STATE_INCOMPLETE === $this->parser_state
1164-
) {
1161+
if ( self::STATE_INCOMPLETE === $this->parser_state ) {
11651162
return false;
11661163
}
11671164

@@ -2486,10 +2483,26 @@ public function is_tag_closer() {
24862483
);
24872484
}
24882485

2486+
public function get_node_type() {
2487+
switch ( $this->parser_state ) {
2488+
case self::STATE_MATCHED_TAG:
2489+
return '#tag';
2490+
2491+
case self::STATE_DOCTYPE:
2492+
return '#doctype';
2493+
2494+
case self::STATE_PI_NODE:
2495+
return '#processing-instruction';
2496+
2497+
default:
2498+
return $this->get_node_name();
2499+
}
2500+
}
2501+
24892502
public function get_node_name() {
24902503
switch ( $this->parser_state ) {
24912504
case self::STATE_MATCHED_TAG:
2492-
return substr( $this->html, $this->tag_name_starts_at, $this->tag_name_length );
2505+
return $this->get_tag();
24932506

24942507
case self::STATE_TEXT_NODE:
24952508
return '#text';

0 commit comments

Comments
 (0)