HTML API: Preserve ::set_modifiable_text() TEXTAREA leading newlines.
HTML specifies that a single newline is ignored at the start of a `TEXTAREA`. If `::set_modifiable_text()` is called with a leading newline, ensure it is preserved in the resulting HTML. Developed in https://github.com/WordPress/wordpress-develop/pull/11062. Props jonsurrell, dmsnell. See #64609. Built from https://develop.svn.wordpress.org/trunk@61754 git-svn-id: http://core.svn.wordpress.org/trunk@61060 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -3877,6 +3877,17 @@ class WP_HTML_Tag_Processor {
|
||||
$plaintext_content
|
||||
);
|
||||
|
||||
/*
|
||||
* HTML ignores a single leading newline in this context. If a leading newline
|
||||
* is intended, preserve it by adding an extra newline.
|
||||
*/
|
||||
if (
|
||||
'TEXTAREA' === $this->get_tag() &&
|
||||
1 === strspn( $plaintext_content, "\n\r", 0, 1 )
|
||||
) {
|
||||
$plaintext_content = "\n{$plaintext_content}";
|
||||
}
|
||||
|
||||
/*
|
||||
* These don't _need_ to be escaped, but since they are decoded it's
|
||||
* safe to leave them escaped and this can prevent other code from
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '7.0-beta2-61753';
|
||||
$wp_version = '7.0-beta2-61754';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
||||
Reference in New Issue
Block a user