Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
});
// fixes font-size when unit (pt|px) is not defined
ast.children.forEach(child => {
if (child.property === 'font-size') {
child.value.children.forEach(value => {
if (value.type === 'Number') {
const fontSize = value.value.toString();
if (!(fontSize.indexOf('pt') >= 0 || fontSize.indexOf('px') >= 0)) {
value.value = `${fontSize}pt`;
}
}
});
}
});
return csstree.generate(ast);
}
}
// Use second pass to replace locally defined animations with scoped names
walk(ast, {
visit: 'Declaration',
enter(node) {
if (cssName(node.property) === 'animation' || cssName(node.property) === 'animation-name') {
walk(node.value, value => {
if (value.type === 'Identifier' && value.name in animations) {
value.name = animations[value.name];
}
});
}
}
});
return generate(ast, options);
};
function decodeFontName (node) {
let name = csstree.generate(node)
// TODO: use string decode
if (name[0] === '"' || name[0] === "'") {
name = name.substr(1, name.length - 2)
}
return name
}
return selectors.filter(({ atrule }) => {
if (atrule === null) {
return true;
}
const { name, prelude } = atrule;
const atPrelude = prelude as AtrulePrelude;
const first = atPrelude && atPrelude.children.first();
const mq = first && first.type === 'MediaQueryList';
const query = mq ? csstree.generate(atPrelude) : name;
return useMqs.includes(query);
});
}
const cleanedStyles = styleSheets.map(ast => {
const cleanedAST = fromPlainObject(cleaner(ast, checker))
return generate(cleanedAST)
})
const finalCSS = collectImportantComments(cleanedStyles.join('\n'))
list.insertData(dataToInsert, item)
} else if (item.next == null) {
list.appendData(dataToInsert)
} else {
list.insertData(dataToInsert, item.next)
}
isChunkDone = true
return
}
})
}
})
},
})
const output = csstree.generate(ast)
return output
}
.forEach(entry => {
const name = utils.unquoteString(
csstree.generate({
type: 'Value',
children: entry.nodes
})
);
activeFontFamilyNames.add(name);
});
}
}
list[son.property]=ans;
}else list[son.property]=item;
}
});
for(let name in list)if(!name.startsWith('-'))
for(let type of removeType){
let fullName=`-${type}-${name}`;
if(list[fullName]){
node.children.remove(list[fullName]);
delete list[fullName];
}
}
}
});
return cssbeautify(csstree.generate(ast),{indent:' ',autosemicolon:true});
}
wu.scanDirByExt(dir,".html",files=>{
return selectors.filter(function(selector) {
if (selector.atrule === null) {
return ~useMqs.indexOf('');
}
var mqName = selector.atrule.name;
var mqStr = mqName;
if (selector.atrule.expression &&
selector.atrule.expression.children.first().type === 'MediaQueryList') {
var mqExpr = csstree.generate(selector.atrule.expression);
mqStr = [mqName, mqExpr].join(' ');
}
return ~useMqs.indexOf(mqStr);
});
}
return selectors.filter(({ pseudos }) =>
usePseudos.includes(
csstree.generate({
type: 'Selector',
children: new List().fromArray(
pseudos.map(pseudo => pseudo.item.data),
),
}),
),
);