@@ -1136,10 +1136,12 @@ module.exports = {
11361136 // attrs: { href: '/some/path', rel: 'stylesheet' }
11371137 // }
11381138 // ]
1139- // Node objects SHOULD have either `name` or `text ` property.
1139+ // Node object SHOULD have either `name`, `text`, `raw` or `comment ` property.
11401140 // A node with `name` can have `attrs` (array of element attributes)
1141- // and `body` (array of child nodes).
1142- // `text` nodes are rendered as text (no HTML tags).
1141+ // and `body` (array of child nodes, recursion).
1142+ // `text` nodes are rendered as text (no HTML tags), the value is always a string.
1143+ // `comment` nodes are rendered as HTML comments, the value is always a string.
1144+ // `raw` nodes are rendered as is, no escaping, the value is always a string.
11431145 renderNodes ( nodes ) {
11441146 if ( ! Array . isArray ( nodes ) ) {
11451147 self . logError (
@@ -1152,10 +1154,22 @@ module.exports = {
11521154 if ( node . text ) {
11531155 return self . apos . util . escapeHtml ( node . text ) ;
11541156 }
1157+ if ( node . comment ) {
1158+ return `\n<!-- ${ self . apos . util . escapeHtml ( node . comment ) } -->\n` ;
1159+ }
1160+ if ( node . raw ) {
1161+ return node . raw ;
1162+ }
11551163 if ( node . name ) {
11561164 const name = self . apos . util . escapeHtml ( node . name ) ;
11571165 const attrs = Object . entries ( node . attrs || { } )
11581166 . map ( ( [ key , value ] ) => {
1167+ if ( value === false || value === null || value === undefined ) {
1168+ return '' ;
1169+ }
1170+ if ( value === true ) {
1171+ return ` ${ self . apos . util . escapeHtml ( key ) } ` ;
1172+ }
11591173 return ` ${ self . apos . util . escapeHtml ( key ) } ="${ self . apos . util . escapeHtml ( value ) } "` ;
11601174 } )
11611175 . join ( '' )
0 commit comments