@@ -3069,7 +3069,7 @@ function renderAstNode(data, options, sourcemap, position, errors, reducer, cach
30693069 return `${ data . nam } :${ options . indent } ${ data . val . reduce ( reducer , '' ) } ` ;
30703070 case exports . EnumToken . CommentNodeType :
30713071 case exports . EnumToken . CDOCOMMNodeType :
3072- if ( data . val . startsWith ( '# sourceMappingURL=' ) ) {
3072+ if ( data . val . startsWith ( '/* # sourceMappingURL=' ) ) {
30733073 // ignore sourcemap
30743074 return '' ;
30753075 }
@@ -3081,12 +3081,12 @@ function renderAstNode(data, options, sourcemap, position, errors, reducer, cach
30813081 return css ;
30823082 }
30833083 if ( css === '' ) {
3084- if ( sourcemap != null ) {
3084+ if ( sourcemap != null && node . loc != null ) {
30853085 updateSourceMap ( node , options , cache , sourcemap , position , str ) ;
30863086 }
30873087 return str ;
30883088 }
3089- if ( sourcemap != null ) {
3089+ if ( sourcemap != null && node . loc != null ) {
30903090 update ( position , options . newLine ) ;
30913091 updateSourceMap ( node , options , cache , sourcemap , position , str ) ;
30923092 }
@@ -6065,12 +6065,13 @@ async function doParse(iterator, options = {}) {
60656065 nestingRules : false ,
60666066 resolveImport : false ,
60676067 resolveUrls : false ,
6068- removeCharset : false ,
6068+ removeCharset : true ,
60696069 removeEmpty : true ,
60706070 removeDuplicateDeclarations : true ,
60716071 computeShorthand : true ,
60726072 computeCalcExpression : true ,
60736073 inlineCssVariables : false ,
6074+ setParent : true ,
60746075 ...options
60756076 } ;
60766077 if ( options . expandNestingRules ) {
@@ -6218,17 +6219,21 @@ async function doParse(iterator, options = {}) {
62186219 minify ( ast , options , true , errors , false ) ;
62196220 }
62206221 }
6221- const nodes = [ ast ] ;
6222- let node ;
6223- while ( ( node = nodes . shift ( ) ) ) {
6224- // @ts -ignore
6225- if ( node . chi . length > 0 ) {
6222+ if ( options . setParent ) {
6223+ const nodes = [ ast ] ;
6224+ let node ;
6225+ while ( ( node = nodes . shift ( ) ) ) {
62266226 // @ts -ignore
6227- for ( const child of node . chi ) {
6228- Object . defineProperty ( child , 'parent' , { ...definedPropertySettings , value : node } ) ;
6229- if ( 'chi' in child && child . chi . length > 0 ) {
6230- // @ts -ignore
6231- nodes . push ( child ) ;
6227+ if ( node . chi . length > 0 ) {
6228+ // @ts -ignore
6229+ for ( const child of node . chi ) {
6230+ if ( child . parent != node ) {
6231+ Object . defineProperty ( child , 'parent' , { ...definedPropertySettings , value : node } ) ;
6232+ }
6233+ if ( 'chi' in child && child . chi . length > 0 ) {
6234+ // @ts -ignore
6235+ nodes . push ( child ) ;
6236+ }
62326237 }
62336238 }
62346239 }
@@ -6380,6 +6385,7 @@ async function parseNode(results, context, stats, options, errors, src, map) {
63806385 const root = await options . load ( url , options . src ) . then ( ( src ) => {
63816386 return doParse ( src , Object . assign ( { } , options , {
63826387 minify : false ,
6388+ setParent : false ,
63836389 // @ts -ignore
63846390 src : options . resolve ( url , options . src ) . absolute
63856391 } ) ) ;
@@ -8194,14 +8200,6 @@ class PropertyList {
81948200 declarations ;
81958201 constructor ( options = { } ) {
81968202 this . options = options ;
8197- // for (const key of Object.keys(this.options)) {
8198- //
8199- // if (key in options) {
8200- //
8201- // // @ts -ignore
8202- // this.options[key] = options[key];
8203- // }
8204- // }
82058203 this . declarations = new Map ;
82068204 }
82078205 set ( nam , value ) {
0 commit comments