Make WordPress Core


Ignore:
Timestamp:
07/24/2024 06:39:46 PM (2 years ago)
Author:
dmsnell
Message:

HTML API: Add TABLE support in HTML Processor.

As part of work to add more spec support to the HTML API, this patch adds
support for various table-related insertion modes. This includes support
for tables, table rows, table cells, table column groups, etc...

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

Props: dmsnell, jonsurrell.
See #61576.

File:
1 edited

Legend:

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

    r58779 r58806  
    425425                $this->assertNull( $processor->get_attribute_names_with_prefix( '' ), 'Should have ignored any attributes on the tag.' );
    426426        }
     427
     428        /*******************************************************************
     429         * RULES FOR "IN TABLE" MODE
     430         *******************************************************************/
     431
     432        /**
     433         * Ensure that form elements in tables (but not cells) are immediately popped off the stack.
     434         *
     435         * @ticket 61576
     436         */
     437        public function test_table_form_element_immediately_popped() {
     438                $processor = WP_HTML_Processor::create_fragment( '<table><form><!--comment-->' );
     439
     440                // There should be a FORM opener and a (virtual) FORM closer.
     441                $this->assertTrue( $processor->next_tag( 'FORM' ) );
     442                $this->assertTrue( $processor->next_token() );
     443                $this->assertSame( 'FORM', $processor->get_token_name() );
     444                $this->assertTrue( $processor->is_tag_closer() );
     445
     446                // Followed by the comment token.
     447                $this->assertTrue( $processor->next_token() );
     448                $this->assertSame( '#comment', $processor->get_token_name() );
     449                $this->assertsame( array( 'HTML', 'BODY', 'TABLE', '#comment' ), $processor->get_breadcrumbs() );
     450        }
    427451}
Note: See TracChangeset for help on using the changeset viewer.