mirror of
https://github.com/svg/svgo.git
synced 2025-07-29 20:21:14 +03:00
Upgrade css-tree from alpha25 to alpha.28
API changed walkFoo(ast, fun) to walk(ast,{visit: 'Rule',enter: fun) csstree.translate renamed to csstree.generate csstree.generate throws an error on invalid style where translate silently ignored it - update style processing to catch and ignore instead Updated tests - csstree now omits more whitespace
This commit is contained in:
committed by
Lev Solntsev
parent
e928c1f050
commit
e7b8a6ce7d
@ -15,7 +15,7 @@ var csstree = require('css-tree'),
|
||||
function flattenToSelectors(cssAst) {
|
||||
var selectors = [];
|
||||
|
||||
csstree.walkRules(cssAst, function(node) {
|
||||
csstree.walk(cssAst, {visit: 'Rule', enter: function(node) {
|
||||
if (node.type !== 'Rule') {
|
||||
return;
|
||||
}
|
||||
@ -43,7 +43,7 @@ function flattenToSelectors(cssAst) {
|
||||
|
||||
selectors.push(selector);
|
||||
});
|
||||
});
|
||||
}});
|
||||
|
||||
return selectors;
|
||||
}
|
||||
@ -65,7 +65,7 @@ function filterByMqs(selectors, useMqs) {
|
||||
var mqStr = mqName;
|
||||
if (selector.atrule.expression &&
|
||||
selector.atrule.expression.children.first().type === 'MediaQueryList') {
|
||||
var mqExpr = csstree.translate(selector.atrule.expression);
|
||||
var mqExpr = csstree.generate(selector.atrule.expression);
|
||||
mqStr = [mqName, mqExpr].join(' ');
|
||||
}
|
||||
|
||||
@ -82,7 +82,7 @@ function filterByMqs(selectors, useMqs) {
|
||||
*/
|
||||
function filterByPseudos(selectors, usePseudos) {
|
||||
return selectors.filter(function(selector) {
|
||||
var pseudoSelectorsStr = csstree.translate({
|
||||
var pseudoSelectorsStr = csstree.generate({
|
||||
type: 'Selector',
|
||||
children: new List().fromArray(selector.pseudos.map(function(pseudo) {
|
||||
return pseudo.item.data;
|
||||
@ -165,7 +165,7 @@ function sortSelectors(selectors) {
|
||||
*/
|
||||
function csstreeToStyleDeclaration(declaration) {
|
||||
var propertyName = declaration.property,
|
||||
propertyValue = csstree.translate(declaration.value),
|
||||
propertyValue = csstree.generate(declaration.value),
|
||||
propertyPriority = (declaration.important ? 'important' : '');
|
||||
return {
|
||||
name: propertyName,
|
||||
|
Reference in New Issue
Block a user