Make WordPress Core


Ignore:
Timestamp:
03/12/2024 12:22:40 AM (9 months ago)
Author:
dmsnell
Message:

HTML API: Trigger active format reconstruction when reaching text nodes.

When encountering text nodes in an HTML document, the HTML parser needs
to run the active format reconstruction algorithm, even if it doesn't
stop to visit those text nodes. This is because the formats, which might
need reconstructing, will impact the breadcrumbs of all downstream nodes
from the text node.

In this patch, this process is triggered, which properly triggers the
active format reconstruction. It also enables the visiting of other token
types as is possible in the Tag Processor.

Developed in https://github.com/WordPress/wordpress-develop/pull/6054
Discussed in https://core.trac.wordpress.org/ticket/60170

Props: dmsnell, jonsurrell, westonruter.
Fixes: #60455.
Follow-up to: [57348].

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/html-api/wpHtmlProcessorSemanticRules.php

    r57508 r57806  
    129129        $this->assertFalse( $processor->is_tag_closer(), 'Did not find that initial DIV tag is an opener.' );
    130130
     131        $processor->step();
     132        $this->assertSame( '#text', $processor->get_token_type(), 'Should have found the text node.' );
     133
    131134        /*
    132135         * When encountering the BUTTON closing tag, there is no BUTTON in the stack of open elements.
Note: See TracChangeset for help on using the changeset viewer.