Changeset 57115
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/html-api/class-wp-html-processor.php
r57077 r57115 100 100 * The following list specifies the HTML tags that _are_ supported: 101 101 * 102 * - Containers: ADDRESS, BLOCKQUOTE, DETAILS, DIALOG, DIV, FOOTER, HEADER, MAIN, MENU, SPAN, SUMMARY. 103 * - Form elements: BUTTON, FIELDSET, SEARCH. 104 * - Formatting elements: B, BIG, CODE, EM, FONT, I, SMALL, STRIKE, STRONG, TT, U. 105 * - Heading elements: HGROUP. 102 106 * - Links: A. 103 * - The formatting elements: B, BIG, CODE, EM, FONT, I, SMALL, STRIKE, STRONG, TT, U. 104 * - Containers: DIV, FIGCAPTION, FIGURE, SPAN. 105 * - Form elements: BUTTON. 107 * - Lists: DL. 108 * - Media elements: FIGCAPTION, FIGURE, IMG. 106 109 * - Paragraph: P. 107 * - Void elements: IMG. 110 * - Sectioning elements: ARTICLE, ASIDE, NAV, SECTION 111 * - Deprecated elements: CENTER, DIR 108 112 * 109 113 * ### Supported markup … … 622 626 * > "main", "menu", "nav", "ol", "p", "search", "section", "summary", "ul" 623 627 */ 628 case '+ADDRESS': 629 case '+ARTICLE': 630 case '+ASIDE': 624 631 case '+BLOCKQUOTE': 632 case '+CENTER': 633 case '+DETAILS': 634 case '+DIALOG': 635 case '+DIR': 625 636 case '+DIV': 637 case '+DL': 638 case '+FIELDSET': 626 639 case '+FIGCAPTION': 627 640 case '+FIGURE': 641 case '+FOOTER': 642 case '+HEADER': 643 case '+HGROUP': 644 case '+MAIN': 645 case '+MENU': 646 case '+NAV': 628 647 case '+P': 648 case '+SEARCH': 649 case '+SECTION': 650 case '+SUMMARY': 629 651 if ( $this->state->stack_of_open_elements->has_p_in_button_scope() ) { 630 652 $this->close_a_p_element(); … … 640 662 * > "menu", "nav", "ol", "pre", "search", "section", "summary", "ul" 641 663 */ 664 case '-ADDRESS': 665 case '-ARTICLE': 666 case '-ASIDE': 642 667 case '-BLOCKQUOTE': 643 668 case '-BUTTON': 669 case '-CENTER': 670 case '-DETAILS': 671 case '-DIALOG': 672 case '-DIR': 644 673 case '-DIV': 674 case '-DL': 675 case '-FIELDSET': 645 676 case '-FIGCAPTION': 646 677 case '-FIGURE': 678 case '-FOOTER': 679 case '-HEADER': 680 case '-HGROUP': 681 case '-MAIN': 682 case '-MENU': 683 case '-NAV': 684 case '-SEARCH': 685 case '-SECTION': 686 case '-SUMMARY': 647 687 if ( ! $this->state->stack_of_open_elements->has_element_in_scope( $tag_name ) ) { 648 688 // @TODO: Report parse error. -
trunk/tests/phpunit/tests/html-api/wpHtmlProcessorBreadcrumbs.php
r56943 r57115 38 38 $supported_elements = array( 39 39 'A', 40 'ADDRESS', 41 'ARTICLE', 42 'ASIDE', 40 43 'B', 41 44 'BIG', 42 45 'BUTTON', 46 'CENTER', // Neutralized 43 47 'CODE', 48 'DETAILS', 49 'DIALOG', 50 'DIR', 44 51 'DIV', 52 'DL', 45 53 'EM', 54 'FIELDSET', 46 55 'FIGCAPTION', 47 56 'FIGURE', 48 57 'FONT', 58 'FOOTER', 59 'HEADER', 60 'HGROUP', 49 61 'I', 50 62 'IMG', 63 'MAIN', 64 'MENU', 65 'NAV', 51 66 'P', 67 'SEARCH', 68 'SECTION', 52 69 'SMALL', 53 70 'SPAN', 54 71 'STRIKE', 55 72 'STRONG', 73 'SUMMARY', 56 74 'TT', 57 75 'U', … … 100 118 'ABBR', 101 119 'ACRONYM', // Neutralized 102 'ADDRESS',103 120 'APPLET', // Deprecated 104 121 'AREA', 105 'ARTICLE',106 'ASIDE',107 122 'AUDIO', 108 123 'BASE', … … 115 130 'CANVAS', 116 131 'CAPTION', 117 'CENTER', // Neutralized118 132 'CITE', 119 133 'COL', … … 123 137 'DD', 124 138 'DEL', 125 'DETAILS',126 139 'DEFN', 127 'DIALOG',128 'DL',129 140 'DT', 130 141 'EMBED', 131 'FIELDSET',132 'FOOTER',133 142 'FORM', 134 143 'FRAME', … … 141 150 'H6', 142 151 'HEAD', 143 'HEADER',144 'HGROUP',145 152 'HR', 146 153 'HTML', … … 156 163 'LINK', 157 164 'LISTING', // Deprecated, use PRE instead. 158 'MAIN',159 165 'MAP', 160 166 'MARK', 161 167 'MARQUEE', // Deprecated 162 168 'MATH', 163 'MENU',164 169 'META', 165 170 'METER', 166 171 'MULTICOL', // Deprecated 167 'NAV',168 172 'NEXTID', // Deprecated 169 173 'NOBR', // Neutralized … … 188 192 'SAMP', 189 193 'SCRIPT', 190 'SECTION',191 194 'SELECT', 192 195 'SLOT', … … 195 198 'STYLE', 196 199 'SUB', 197 'SUMMARY',198 200 'SUP', 199 201 'SVG', … … 349 351 2, 350 352 ), 353 'MAIN inside MAIN inside SPAN' => array( '<span><main><main target>', array( 'HTML', 'BODY', 'SPAN', 'MAIN', 'MAIN' ), 1 ), 354 'MAIN next to unclosed P' => array( '<p><main target>', array( 'HTML', 'BODY', 'MAIN' ), 1 ), 351 355 ); 352 356 } -
trunk/tests/phpunit/tests/html-api/wpHtmlProcessorSemanticRules.php
r56790 r57115 18 18 19 19 /** 20 * Verifies that tags in the container group, including the ARTICLE element, 21 * close out an open P element if one exists. 22 * 23 * @covers WP_HTML_Processor::step_in_body 24 * 25 * @ticket 59914 26 * 27 * @dataProvider data_article_container_group 28 * 29 * @param string $tag_name Name of tag in group under test. 30 */ 31 public function test_in_body_article_group_closes_open_p_element( $tag_name ) { 32 $processor = WP_HTML_Processor::create_fragment( "<p><p><p><p><{$tag_name} target>" ); 33 34 while ( $processor->next_tag() && null === $processor->get_attribute( 'target' ) ) { 35 continue; 36 } 37 38 $this->assertEquals( 39 $tag_name, 40 $processor->get_tag(), 41 "Expected to find {$tag_name} but found {$processor->get_tag()} instead." 42 ); 43 44 $this->assertSame( 45 array( 'HTML', 'BODY', $tag_name ), 46 $processor->get_breadcrumbs(), 47 "Expected to find {$tag_name} as direct child of BODY as a result of implicitly closing an open P element." 48 ); 49 } 50 51 /** 52 * Verifies that tags in the container group, including the ARTICLE element, 53 * nest inside each other despite being invalid in most cases. 54 * 55 * @covers WP_HTML_Processor::step_in_body 56 * 57 * @ticket 59914 58 * 59 * @dataProvider data_article_container_group 60 * 61 * @param string $tag_name Name of tag in group under test. 62 */ 63 public function test_in_body_article_group_can_nest_inside_itself( $tag_name ) { 64 $processor = WP_HTML_Processor::create_fragment( "<div><{$tag_name}><{$tag_name}></{$tag_name}><{$tag_name}><span><{$tag_name} target>" ); 65 66 while ( $processor->next_tag() && null === $processor->get_attribute( 'target' ) ) { 67 continue; 68 } 69 70 $this->assertSame( 71 array( 'HTML', 'BODY', 'DIV', $tag_name, $tag_name, 'SPAN', $tag_name ), 72 $processor->get_breadcrumbs(), 73 "Expected to find {$tag_name} deeply nested inside itself." 74 ); 75 } 76 77 /** 78 * Data provider. 79 * 80 * @return array[]. 81 */ 82 public function data_article_container_group() { 83 $group = array(); 84 85 foreach ( 86 array( 87 'ADDRESS', 88 'ARTICLE', 89 'ASIDE', 90 'BLOCKQUOTE', 91 'CENTER', 92 'DETAILS', 93 'DIALOG', 94 'DIR', 95 'DL', 96 'DIV', 97 'FIELDSET', 98 'FIGCAPTION', 99 'FIGURE', 100 'FOOTER', 101 'HEADER', 102 'HGROUP', 103 'MAIN', 104 'MENU', 105 'NAV', 106 'SEARCH', 107 'SECTION', 108 'SUMMARY', 109 ) 110 as $tag_name 111 ) { 112 $group[ $tag_name ] = array( $tag_name ); 113 } 114 115 return $group; 116 } 117 118 /** 20 119 * Verifies that when encountering an end tag for which there is no corresponding 21 120 * element in scope, that it skips the tag entirely. … … 143 242 * element on the stack of open elements before the matching opening. 144 243 * 244 * @covers WP_HTML_Processor::step_in_body 245 * 145 246 * @ticket 58907 146 247 * 147 248 * @since 6.4.0 148 *149 * @covers WP_HTML_Processor::step_in_body150 249 */ 151 250 public function test_in_body_any_other_end_tag_with_unclosed_special_element() { … … 166 265 * open elements up to the matching opening. 167 266 * 267 * @covers WP_HTML_Processor::step_in_body 268 * 168 269 * @ticket 58907 169 270 * 170 271 * @since 6.4.0 171 *172 * @covers WP_HTML_Processor::step_in_body173 272 */ 174 273 public function test_in_body_any_other_end_tag_with_unclosed_non_special_element() {
Note: See TracChangeset
for help on using the changeset viewer.