@ -1851,18 +1851,27 @@ function serialize_element_attributes(node, context) {
for ( const attribute of node . attributes ) {
for ( const attribute of node . attributes ) {
if ( attribute . type === 'Attribute' ) {
if ( attribute . type === 'Attribute' ) {
if ( attribute . name === 'value' && node . name === 'textarea' ) {
if ( attribute . name === 'value' ) {
if (
if ( node . name === 'textarea' ) {
attribute . value !== true &&
if (
attribute . value [ 0 ] . type === 'Text' &&
attribute . value !== true &&
regex _starts _with _newline . test ( attribute . value [ 0 ] . data )
attribute . value [ 0 ] . type === 'Text' &&
) {
regex _starts _with _newline . test ( attribute . value [ 0 ] . data )
// Two or more leading newlines are required to restore the leading newline immediately after `<textarea>`.
) {
// see https://html.spec.whatwg.org/multipage/syntax.html#element-restrictions
// Two or more leading newlines are required to restore the leading newline immediately after `<textarea>`.
// also see related code in analysis phase
// see https://html.spec.whatwg.org/multipage/syntax.html#element-restrictions
attribute . value [ 0 ] . data = '\n' + attribute . value [ 0 ] . data ;
// also see related code in analysis phase
attribute . value [ 0 ] . data = '\n' + attribute . value [ 0 ] . data ;
}
content = {
escape : true ,
expression : serialize _attribute _value ( attribute . value , context )
} ;
} else if ( node . name !== 'select' ) {
// omit value attribute for select elements, it's irrelevant for the initially selected value and has no
// effect on the selected value after the user interacts with the select element (the value _property_ does, but not the attribute)
attributes . push ( attribute ) ;
}
}
content = { escape : true , expression : serialize _attribute _value ( attribute . value , context ) } ;
// omit event handlers except for special cases
// omit event handlers except for special cases
} else if ( is _event _attribute ( attribute ) ) {
} else if ( is _event _attribute ( attribute ) ) {