@@ -91,12 +91,15 @@ function getAttributes(
9191 * @param {array } styleElements
9292 */
9393function getStyleContents ( element : IHtmlNode ) : IHtmlNode {
94+ const content = element . children
95+ . filter ( ( x ) => x . type == 'text' )
96+ . map ( ( x ) => x . content )
97+ . join ( '' )
98+
9499 return < IHtmlNode > ( < unknown > {
95100 tagName : 'style' ,
96101 text : 'STYLE' ,
97- filterAttributes : {
98- style : element . content ,
99- } ,
102+ content : content ,
100103 } )
101104}
102105
@@ -231,6 +234,7 @@ function getSassTree(nodeTree: IHtmlNode[] | IHtmlNode, deepth = 0) {
231234
232235 if ( Array . isArray ( node . children ) && node . children . length ) {
233236 ++ deepth
237+
234238 subTreeString = getSassTree ( node , deepth )
235239 }
236240
@@ -297,7 +301,7 @@ function getHtmlTree(nodeTree: IHtmlNode[], deepth = 0): string {
297301
298302 nodeTree . forEach ( function ( node : IHtmlNode , index ) {
299303 const className = getClassName ( node , deepth )
300- if ( node . type == 'element' ) {
304+ if ( node . type == 'element' && node . tagName != 'style' ) {
301305 if ( _defaultOptions . printComments ) {
302306 if ( node . comment ) {
303307 htmlTree += `\n<!-- ${ node . comment . trim ( ) } -->`
@@ -365,7 +369,6 @@ function getHtmlTree(nodeTree: IHtmlNode[], deepth = 0): string {
365369 ( ! isVoidElement ? `</${ node . tagName } >` : '' ) +
366370 ( ! isNextNodeSibling ? '\n' : '' )
367371 } else if ( node . type == 'text' ) {
368- // inner text
369372 htmlTree += node . content ? `\n${ node . content } \n` : ''
370373 }
371374 } )
0 commit comments