Skip to content

Commit

Permalink
HTML API: Fix three small type-related bugs.
Browse files Browse the repository at this point in the history
This applies three fixes that appeared as part of
adding type annotations to the HTML API.

Developed in #6754
Discussed in https://core.trac.wordpress.org/ticket/61399

Props jonsurrell.
See #61399.
Follow-up to [55203], [56274].


git-svn-id: https://develop.svn.wordpress.org/trunk@58364 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
dmsnell committed Jun 8, 2024
1 parent 0cad031 commit 1626aac
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/wp-includes/html-api/class-wp-html-processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ public function next_token() {
// Avoid sending close events for elements which don't expect a closing.
if (
WP_HTML_Stack_Event::POP === $this->current_element->operation &&
! static::expects_closer( $this->current_element->token->node_name )
! static::expects_closer( $this->current_element->token )
) {
return $this->next_token();
}
Expand Down
6 changes: 4 additions & 2 deletions src/wp-includes/html-api/class-wp-html-tag-processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -2265,7 +2265,7 @@ private function class_name_updates_to_attributes_updates() {
* @param int $shift_this_point Accumulate and return shift for this position.
* @return int How many bytes the given pointer moved in response to the updates.
*/
private function apply_attributes_updates( $shift_this_point = 0 ) {
private function apply_attributes_updates( $shift_this_point ) {
if ( ! count( $this->lexical_updates ) ) {
return 0;
}
Expand Down Expand Up @@ -2787,6 +2787,8 @@ public function get_token_name() {
case self::STATE_FUNKY_COMMENT:
return '#funky-comment';
}

return null;
}

/**
Expand Down Expand Up @@ -3195,7 +3197,7 @@ public function get_updated_html() {
* Keep track of the position right before the current tag. This will
* be necessary for reparsing the current tag after updating the HTML.
*/
$before_current_tag = $this->token_starts_at;
$before_current_tag = $this->token_starts_at ?? 0;

/*
* 1. Apply the enqueued edits and update all the pointers to reflect those changes.
Expand Down

0 comments on commit 1626aac

Please sign in to comment.