Skip to content

Commit

Permalink
Fix set_bookmark
Browse files Browse the repository at this point in the history
  • Loading branch information
dmsnell committed Dec 18, 2023
1 parent e83ff85 commit 156a31e
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions src/wp-includes/html-api/class-wp-html-tag-processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -1158,10 +1158,7 @@ public function has_class( $wanted_class ) {
*/
public function set_bookmark( $name ) {
// It only makes sense to set a bookmark if the parser has paused on a concrete token.
if (
self::STATE_COMPLETE === $this->parser_state ||
self::STATE_INCOMPLETE === $this->parser_state
) {
if ( self::STATE_INCOMPLETE === $this->parser_state ) {
return false;
}

Expand Down Expand Up @@ -2486,10 +2483,26 @@ public function is_tag_closer() {
);
}

public function get_node_type() {
switch ( $this->parser_state ) {
case self::STATE_MATCHED_TAG:
return '#tag';

case self::STATE_DOCTYPE:
return '#doctype';

case self::STATE_PI_NODE:
return '#processing-instruction';

default:
return $this->get_node_name();
}
}

public function get_node_name() {
switch ( $this->parser_state ) {
case self::STATE_MATCHED_TAG:
return substr( $this->html, $this->tag_name_starts_at, $this->tag_name_length );
return $this->get_tag();

case self::STATE_TEXT_NODE:
return '#text';
Expand Down

0 comments on commit 156a31e

Please sign in to comment.