Skip to content

Commit

Permalink
Code refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
dmsnell committed Apr 23, 2023
1 parent 61346f5 commit 55ead4f
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/wp-includes/html-api/class-wp-html-tag-processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -2165,19 +2165,15 @@ public function get_updated_html() {
}

// Apply the updates, rewind to before the current tag, and reparse the attributes.
$content_up_to_opened_tag_name = $this->output_buffer . substr(
$this->html,
$this->bytes_already_copied,
$this->tag_name_starts_at + $this->tag_name_length - $this->bytes_already_copied
);
$start_of_current_tag = strlen( $this->output_buffer ) + ( $this->tag_name_starts_at - $this->bytes_already_copied ) - 1;

/*
* 1. Apply the edits by flushing them to the output buffer and updating the copied byte count.
*
* Note: `apply_attributes_updates()` modifies `$this->output_buffer`.
*/
$this->class_name_updates_to_attributes_updates();
$tag_adjust = $this->apply_attributes_updates( strlen( $content_up_to_opened_tag_name ) - $this->tag_name_length - 1 );
$start_of_current_tag += $this->apply_attributes_updates( $start_of_current_tag );

/*
* 2. Replace the original HTML with the now-updated HTML so that it's possible to
Expand All @@ -2200,8 +2196,8 @@ public function get_updated_html() {
* ^ | back up by the length of the tag name plus the opening <
* \<-/ back up by strlen("em") + 1 ==> 3
*/
$this->bytes_already_parsed = strlen( $content_up_to_opened_tag_name ) + $tag_adjust - $this->tag_name_length - 1;
$this->acccumulated_shift = 0;
$this->bytes_already_parsed = $start_of_current_tag;
$this->acccumulated_shift = 0;
$this->next_tag();

return $this->html;
Expand Down

0 comments on commit 55ead4f

Please sign in to comment.