Make WordPress Core


Ignore:
Timestamp:
08/08/2024 07:23:53 AM (15 months ago)
Author:
dmsnell
Message:

HTML API: Add support for SVG and MathML (Foreign content)

As part of work to add more spec support to the HTML API, this patch adds
support for SVG and MathML elements, or more generally, "foreign content."

The rules in foreign content are a mix of XML and HTML parsing rules and
introduce additional complexity into the processor, but is important in
order to avoid getting lost when inside these elements.

Developed in https://github.com/wordpress/wordpress-develop/pull/6006
Discussed in https://core.trac.wordpress.org/ticket/61576

Props: dmsnell, jonsurrell, westonruter.
See #61576.

File:
1 edited

Legend:

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

    r58828 r58867  
    360360
    361361    /**
    362      * Ensures that special handling of unsupported tags is cleaned up
    363      * as handling is implemented. Otherwise there's risk of leaving special
    364      * handling (that is never reached) when tag handling is implemented.
    365      *
    366      * @ticket 60092
    367      *
    368      * @dataProvider data_unsupported_special_in_body_tags
    369      *
    370      * @covers WP_HTML_Processor::step_in_body
    371      *
    372      * @param string $tag_name Name of the tag to test.
    373      */
    374     public function test_step_in_body_fails_on_unsupported_tags( $tag_name ) {
    375         $fragment = WP_HTML_Processor::create_fragment( '<' . $tag_name . '></' . $tag_name . '>' );
    376         $this->assertFalse( $fragment->next_tag(), 'Should fail to find tag: ' . $tag_name . '.' );
    377         $this->assertEquals( $fragment->get_last_error(), WP_HTML_Processor::ERROR_UNSUPPORTED, 'Should have unsupported last error.' );
    378     }
    379 
    380     /**
    381      * Data provider.
    382      *
    383      * @return array[]
    384      */
    385     public static function data_unsupported_special_in_body_tags() {
    386         return array(
    387             'MATH' => array( 'MATH' ),
    388             'SVG'  => array( 'SVG' ),
    389         );
    390     }
    391 
    392     /**
    393362     * Ensures that the HTML Processor properly reports the depth of a given element.
    394363     *
Note: See TracChangeset for help on using the changeset viewer.