Skip to content

Commit fce641d

Browse files
committed
Use insert_marker over set_marker
Use the method implemented in WordPress#6982 to avoid duplicating the same functionality.
1 parent 2ded522 commit fce641d

2 files changed

Lines changed: 19 additions & 8 deletions

File tree

src/wp-includes/html-api/class-wp-html-active-formatting-elements.php

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,22 @@ public function current_node() {
8686
return $current_node ? $current_node : null;
8787
}
8888

89+
/**
90+
* Inserts a "marker" at the end of the list of active formatting elements.
91+
*
92+
* > The markers are inserted when entering applet, object, marquee,
93+
* > template, td, th, and caption elements, and are used to prevent
94+
* > formatting from "leaking" into applet, object, marquee, template,
95+
* > td, th, and caption elements.
96+
*
97+
* @see https://html.spec.whatwg.org/#concept-parser-marker
98+
*
99+
* @since 6.7.0
100+
*/
101+
public function insert_marker() {
102+
$this->push( new WP_HTML_Token( null, 'marker', false ) );
103+
}
104+
89105
/**
90106
* Pushes a node onto the stack of active formatting elements.
91107
*
@@ -185,10 +201,6 @@ public function walk_up() {
185201
}
186202
}
187203

188-
public function set_marker() {
189-
$this->push( new WP_HTML_Token( null, 'marker', false ) );
190-
}
191-
192204
/**
193205
* Clears the list of active formatting elements up to the last marker.
194206
*
@@ -208,9 +220,8 @@ public function set_marker() {
208220
*/
209221
public function clear_up_to_last_marker(): void {
210222
foreach ( $this->walk_up() as $item ) {
211-
$is_marker = 'marker' === $item->node_name;
212223
array_pop( $this->stack );
213-
if ( $is_marker ) {
224+
if ( 'marker' === $item->node_name ) {
214225
break;
215226
}
216227
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1776,7 +1776,7 @@ private function step_in_table() {
17761776
*/
17771777
case '+CAPTION':
17781778
$this->clear_stack_to_table_context();
1779-
$this->state->active_formatting_elements->set_marker();
1779+
$this->state->active_formatting_elements->insert_marker();
17801780
$this->insert_html_element( $this->state->current_token );
17811781
$this->state->insertion_mode = WP_HTML_Processor_State::INSERTION_MODE_IN_CAPTION;
17821782
return true;
@@ -2113,7 +2113,7 @@ private function step_in_row() {
21132113
case '+TD':
21142114
$this->clear_stack_to_table_row_context();
21152115
$this->insert_html_element( $this->state->current_token );
2116-
$this->state->active_formatting_elements->set_marker();
2116+
$this->state->active_formatting_elements->insert_marker();
21172117
return true;
21182118

21192119
/*

0 commit comments

Comments
 (0)