Make WordPress Core


Ignore:
Timestamp:
01/19/2024 07:01:29 PM (9 months ago)
Author:
dmsnell
Message:

HTML API: Add support for HR element.

Adds support for the following HTML elements to the HTML Processor:

  • HR

Previously, this element was not supported and the HTML Processor would bail when encountering
it. Now, with this patch, it will proceed to parse an HTML document when encountering one.

Developed in WordPress/wordpress-develop#5897

Props jonsurrell, dmsnell
Fixes #60283

File:
1 edited

Legend:

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

    r57264 r57314  
    226226
    227227    /**
     228     * Verifies that HR closes an open p tag
     229     *
     230     * @ticket 60283
     231     */
     232    public function test_in_body_hr_element_closes_open_p_tag() {
     233        $processor = WP_HTML_Processor::create_fragment( '<p><hr>' );
     234
     235        $processor->next_tag( 'HR' );
     236        $this->assertSame(
     237            array( 'HTML', 'BODY', 'HR' ),
     238            $processor->get_breadcrumbs(),
     239            'Expected HR to be a direct child of the BODY, having closed the open P element.'
     240        );
     241    }
     242
     243    /**
    228244     * Verifies that H1 through H6 elements close an open P element.
    229245     *
Note: See TracChangeset for help on using the changeset viewer.