@@ -20,18 +20,18 @@ class Tests_HtmlApi_WpHtmlSupportRequiredActiveFormatReconstruction extends WP_U
2020 * @ticket 60455
2121 */
2222 public function test_reconstructs_active_formats_on_text_nodes () {
23- $ processor = WP_HTML_Processor::create_fragment ( '<p><b>One<span><p >Two<an-element > ' );
23+ $ processor = WP_HTML_Processor::create_fragment ( '<p><b>One<p><source >Two<source > ' );
2424
25- $ processor ->next_tag ( 'span ' );
26- $ this ->assertSame (
27- array ( 'HTML ' , 'BODY ' , 'P ' , 'B ' , 'SPAN ' ),
28- $ processor ->get_breadcrumbs (),
29- 'Should have identified the stack of open elements for the first text node. '
25+ // The SOURCE element doesn't trigger reconstruction, and this test asserts that.
26+ $ this ->assertTrue (
27+ $ processor ->next_tag ( 'SOURCE ' ),
28+ 'Should have found the first custom element. '
3029 );
3130
32- $ this ->assertTrue (
33- $ processor ->next_tag ( 'p ' ),
34- 'Should have found second P element. '
31+ $ this ->assertSame (
32+ array ( 'HTML ' , 'BODY ' , 'P ' , 'SOURCE ' ),
33+ $ processor ->get_breadcrumbs (),
34+ 'Should have closed formatting element at first P element. '
3535 );
3636
3737 /*
@@ -45,11 +45,18 @@ public function test_reconstructs_active_formats_on_text_nodes() {
4545 * To ensure that this test properly works once that support is expanded,
4646 * it's written to verify both circumstances. Once support is added, this
4747 * can be simplified to only contain the first clause of the conditional.
48+ *
49+ * The use of the SOURCE element is important here because most elements
50+ * will also trigger reconstruction, which would conflate the test results
51+ * with the text node triggering reconstruction. The SOURCE element won't
52+ * do this, making it neutral. Therefore, the implicitly-closed B element
53+ * will only be reconstructed by the text node.
4854 */
4955
50- if ( $ processor ->next_tag ( 'AN-ELEMENT ' ) ) {
56+ if ( $ processor ->next_tag ( 'SOURCE ' ) ) {
57+ echo "\e[32mSOURCE \e[m \n" ;
5158 $ this ->assertSame (
52- array ( 'HTML ' , 'BODY ' , 'P ' , 'B ' , 'AN-ELEMENT ' ),
59+ array ( 'HTML ' , 'BODY ' , 'P ' , 'B ' , 'SOURCE ' ),
5360 $ processor ->get_breadcrumbs (),
5461 'Should have reconstructed the implicitly-closed B element. '
5562 );
0 commit comments