mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
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 git-svn-id: https://develop.svn.wordpress.org/trunk@57314 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
27ac620c7a
commit
ecbd1376a6
@ -109,7 +109,7 @@
|
||||
* - Media elements: AUDIO, CANVAS, FIGCAPTION, FIGURE, IMG, MAP, PICTURE, VIDEO.
|
||||
* - Paragraph: P.
|
||||
* - Phrasing elements: ABBR, BDI, BDO, CITE, DATA, DEL, DFN, INS, MARK, OUTPUT, Q, SAMP, SUB, SUP, TIME, VAR.
|
||||
* - Sectioning elements: ARTICLE, ASIDE, NAV, SECTION.
|
||||
* - Sectioning elements: ARTICLE, ASIDE, HR, NAV, SECTION.
|
||||
* - Templating elements: SLOT.
|
||||
* - Text decoration: RUBY.
|
||||
* - Deprecated elements: ACRONYM, BLINK, CENTER, DIR, ISINDEX, MULTICOL, NEXTID, SPACER.
|
||||
@ -941,6 +941,17 @@ class WP_HTML_Processor extends WP_HTML_Tag_Processor {
|
||||
$this->reconstruct_active_formatting_elements();
|
||||
$this->insert_html_element( $this->state->current_token );
|
||||
return true;
|
||||
|
||||
/*
|
||||
* > A start tag whose tag name is "hr"
|
||||
*/
|
||||
case '+HR':
|
||||
if ( $this->state->stack_of_open_elements->has_p_in_button_scope() ) {
|
||||
$this->close_a_p_element();
|
||||
}
|
||||
$this->insert_html_element( $this->state->current_token );
|
||||
$this->state->frameset_ok = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -977,7 +988,6 @@ class WP_HTML_Processor extends WP_HTML_Tag_Processor {
|
||||
case 'FRAME':
|
||||
case 'FRAMESET':
|
||||
case 'HEAD':
|
||||
case 'HR':
|
||||
case 'HTML':
|
||||
case 'IFRAME':
|
||||
case 'INPUT':
|
||||
|
||||
@ -173,7 +173,6 @@ class Tests_HtmlApi_WpHtmlProcessor extends WP_UnitTestCase {
|
||||
'FRAME' => array( 'FRAME' ),
|
||||
'FRAMESET' => array( 'FRAMESET' ),
|
||||
'HEAD' => array( 'HEAD' ),
|
||||
'HR' => array( 'HR' ),
|
||||
'HTML' => array( 'HTML' ),
|
||||
'IFRAME' => array( 'IFRAME' ),
|
||||
'INPUT' => array( 'INPUT' ),
|
||||
|
||||
@ -175,7 +175,6 @@ class Tests_HtmlApi_WpHtmlProcessorBreadcrumbs extends WP_UnitTestCase {
|
||||
'FRAME',
|
||||
'FRAMESET',
|
||||
'HEAD',
|
||||
'HR',
|
||||
'HTML',
|
||||
'IFRAME',
|
||||
'INPUT',
|
||||
|
||||
@ -224,6 +224,22 @@ class Tests_HtmlApi_WpHtmlProcessorSemanticRules extends WP_UnitTestCase {
|
||||
$this->assertSame( array( 'HTML', 'BODY', 'BUTTON' ), $p->get_breadcrumbs(), 'Failed to produce expected DOM nesting for third button.' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that HR closes an open p tag
|
||||
*
|
||||
* @ticket 60283
|
||||
*/
|
||||
public function test_in_body_hr_element_closes_open_p_tag() {
|
||||
$processor = WP_HTML_Processor::create_fragment( '<p><hr>' );
|
||||
|
||||
$processor->next_tag( 'HR' );
|
||||
$this->assertSame(
|
||||
array( 'HTML', 'BODY', 'HR' ),
|
||||
$processor->get_breadcrumbs(),
|
||||
'Expected HR to be a direct child of the BODY, having closed the open P element.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that H1 through H6 elements close an open P element.
|
||||
*
|
||||
|
||||
Loading…
Reference in New Issue
Block a user