File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3298,6 +3298,34 @@ private function run_adoption_agency_algorithm() {
32983298 throw new WP_HTML_Unsupported_Exception ( 'Cannot run adoption agency when looping required. ' );
32993299 }
33003300
3301+ /**
3302+ * Runs the close cell algorithm.
3303+ *
3304+ * @see https://html.spec.whatwg.org/multipage/parsing.html#close-the-cell
3305+ *
3306+ * Where the steps above say to close the cell, they mean to run the following algorithm:
3307+
3308+ * > 1. Generate implied end tags.
3309+ * > 2. If the current node is not now a td element or a th element, then this is a parse error.
3310+ * > 3. Pop elements from the stack of open elements stack until a td element or a th element has been popped from the stack.
3311+ * > 4. Clear the list of active formatting elements up to the last marker.
3312+ * > 5. Switch the insertion mode to "in row".
3313+ *
3314+ * @since 6.7.0
3315+ */
3316+ private function close_cell (): void {
3317+ $ this ->generate_implied_end_tags ();
3318+ // @todo Parse error if the current node is a "td" or "th" element.
3319+ foreach ( $ this ->state ->stack_of_open_elements ->walk_up () as $ element ) {
3320+ $ this ->state ->stack_of_open_elements ->pop ();
3321+ if ( 'TD ' === $ element ->node_name || 'TH ' === $ element ->node_name ) {
3322+ break ;
3323+ }
3324+ }
3325+ $ this ->state ->active_formatting_elements ->clear_up_to_last_marker ();
3326+ $ this ->state ->insertion_mode = WP_HTML_Processor_State::INSERTION_MODE_IN_ROW ;
3327+ }
3328+
33013329 /**
33023330 * Inserts an HTML element on the stack of open elements.
33033331 *
You can’t perform that action at this time.
0 commit comments