Changeset 61754
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/html-api/class-wp-html-tag-processor.php
r61477 r61754 3877 3877 $plaintext_content 3878 3878 ); 3879 3880 /* 3881 * HTML ignores a single leading newline in this context. If a leading newline 3882 * is intended, preserve it by adding an extra newline. 3883 */ 3884 if ( 3885 'TEXTAREA' === $this->get_tag() && 3886 1 === strspn( $plaintext_content, "\n\r", 0, 1 ) 3887 ) { 3888 $plaintext_content = "\n{$plaintext_content}"; 3889 } 3879 3890 3880 3891 /* -
trunk/tests/phpunit/tests/html-api/wpHtmlTagProcessorModifiableText.php
r61477 r61754 637 637 ); 638 638 } 639 640 /** 641 * TEXTAREA elements ignore the first newline in their content. 642 * Setting the modifiable text with a leading newline should ensure that the leading newline 643 * is present in the resulting element. 644 * 645 * @ticket 64609 646 */ 647 public function test_modifiable_text_special_textarea() { 648 $processor = new WP_HTML_Tag_Processor( '<textarea></textarea>' ); 649 $processor->next_token(); 650 $processor->set_modifiable_text( "\nAFTER NEWLINE" ); 651 $this->assertSame( 652 "\nAFTER NEWLINE", 653 $processor->get_modifiable_text(), 654 'Should have preserved the leading newline in the content.' 655 ); 656 $this->assertEqualHTML( 657 <<<'HTML' 658 <textarea> 659 660 AFTER NEWLINE</textarea> 661 HTML, 662 $processor->get_updated_html(), 663 '<body>', 664 'Should have preserved the leading newline in the content.' 665 ); 666 } 639 667 }
Note: See TracChangeset
for help on using the changeset viewer.