Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
enter: function (node) {
// walker pass through `font-family` declarations inside @font-face too
// this condition filters them, to walk through declarations inside a rules only
if (this.rule) {
csstree.lexer
.findDeclarationValueFragments(node, 'Type', 'family-name')
.forEach(entry => {
const familyName = decodeFontName({
type: 'Value',
children: entry.nodes
})
if (!fontNameValues.has(familyName)) {
debuglog('found used font-family: ' + familyName)
fontNameValues.add(familyName)
}
})
}
}
})
var lexer = require('css-tree').lexer;
var packNumber = require('./Number').pack;
var blacklist = new Set([
// see https://github.com/jakubpawlowicz/clean-css/issues/957
'width',
'min-width',
'max-width',
'height',
'min-height',
'max-height'
]);
module.exports = function compressPercentage(node, item) {
node.value = packNumber(node.value, item);
if (node.value === '0' && this.declaration && !blacklist.has(this.declaration.property)) {
// try to convert a number
const postProcessOptimize = ast => {
// First walk the AST to know which animations are ever mentioned
// by the remaining rules.
const activeAnimationNames = new Set(
csstree.lexer
.findAllFragments(ast, 'Type', 'keyframes-name')
.map(entry => csstree.generate(entry.nodes.first()))
);
// This is the function we use to filter @keyframes atrules out,
// if its name is not actively used.
// It also filters out all `@media print` atrules.
csstree.walk(ast, {
visit: 'Atrule',
enter: (node, item, list) => {
const basename = csstree.keyword(node.name).basename;
if (basename === 'keyframes') {
if (!activeAnimationNames.has(csstree.generate(node.prelude))) {
list.remove(item);
}
} else if (basename === 'media') {
var lexer = require('css-tree').lexer;
var packNumber = require('./Number').pack;
// http://www.w3.org/TR/css3-color/#svg-color
var NAME_TO_HEX = {
'aliceblue': 'f0f8ff',
'antiquewhite': 'faebd7',
'aqua': '0ff',
'aquamarine': '7fffd4',
'azure': 'f0ffff',
'beige': 'f5f5dc',
'bisque': 'ffe4c4',
'black': '000',
'blanchedalmond': 'ffebcd',
'blue': '00f',
'blueviolet': '8a2be2',
'brown': 'a52a2a',
enter: function(node) {
// walker pass through `font-family` declarations inside @font-face too
// this condition filter them, to walk through declarations
// inside a rules only.
if (this.rule) {
csstree.lexer
.findDeclarationValueFragments(node, 'Type', 'family-name')
.forEach(entry => {
const name = utils.unquoteString(
csstree.generate({
type: 'Value',
children: entry.nodes
})
);
activeFontFamilyNames.add(name);
});
}
}
});
var fs = require('fs');
var path = require('path');
var csstree = require('css-tree');
var syntax = csstree.lexer;
function defaultShouldBeValidated(filename) {
return path.extname(filename) === '.css';
}
function collectFiles(testPath, shouldBeValidated) {
try {
if (fs.statSync(testPath).isDirectory()) {
return fs.readdirSync(testPath).reduce(function(result, dirFilename) {
return result.concat(collectFiles(path.join(testPath, dirFilename), shouldBeValidated));
}, []);
} else {
return shouldBeValidated(testPath) ? [testPath] : [];
}
} catch (e) {
return [testPath];