Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (POSITION_SAFE_VALUE.indexOf(name) === -1) {
special[name] = true;
}
} else if (DONT_MIX_VALUE.hasOwnProperty(realName)) {
if (DONT_MIX_VALUE[realName].test(name)) {
special[name] = true;
}
}
break;
case 'Function':
var name = node.name;
if (!vendorId) {
vendorId = resolveKeyword(name).vendor;
}
if (name === 'rect') {
// there are 2 forms of rect:
// rect(, , , ) - standart
// rect( ) – backwards compatible syntax
// only the same form values can be merged
var hasComma = node.children.some(function(node) {
return node.type === 'Operator' && node.value === ',';
});
if (!hasComma) {
name = 'rect-backward';
}
}
special[name + '()'] = true;
leave: (atrule, item, list) => {
const name = csstree.keyword(atrule.name).basename
/* ==@-rule handling== */
/* - Case 0 : Non nested @-rule [REMAIN]
(@charset, @import, @namespace)
*/
if (name === 'charset' || name === 'import' || name === 'namespace') {
return
}
/* Case 1: @-rule with CSS properties inside [REMAIN]
@font-face, @keyframes - keep here, but remove later in code, unless it is used.
*/
if (name === 'font-face' || name === 'keyframes' || name === 'viewport') {
return
}
enter: (atrule, atruleItem, atruleList) => {
if (csstree.keyword(atrule.name).basename === 'font-face') {
// We're inside a font-face rule! Let's dig deeper.
csstree.walk(atrule, {
visit: 'Declaration',
enter: declaration => {
if (csstree.property(declaration.property).name === 'font-family') {
const name = utils.unquoteString(
csstree.generate(declaration.value)
);
// was this @font-face used?
if (!activeFontFamilyNames.has(name)) {
atruleList.remove(atruleItem);
}
}
}
});
}
module.exports = function(node) {
// compress @keyframe selectors
if (resolveKeyword(node.name).basename === 'keyframes') {
compressKeyframes(node);
}
};
enter: function(node) {
if (node.prelude) {
node.prelude.id = null; // pre-init property to avoid multiple hidden class for generate
node.prelude.id = generate(node.prelude);
}
// compare keyframe selectors by its values
// NOTE: still no clarification about problems with keyframes selector grouping (issue #197)
if (resolveKeyword(node.name).basename === 'keyframes') {
node.block.avoidRulesMerge = true; /* probably we don't need to prevent those merges for @keyframes
TODO: need to be checked */
node.block.children.each(function(rule) {
rule.prelude.children.each(function(simpleselector) {
simpleselector.compareMarker = simpleselector.id;
});
});
}
}
});
enter: function (rule, item, list) {
// ignore rules inside @keyframes at-rule
if (
this.atrule &&
csstree.keyword(this.atrule.name).basename === 'keyframes'
) {
return
}
// ignore a rule with a bad selector
if (rule.prelude.type !== 'SelectorList') {
return
}
const addedRule = rule.block.children.some(declarationNode => {
if (declarationNode.property === 'grid-area') {
const ruleSelectorList = csstree.generate(rule.prelude)
debuglog('rule contains grid-area, keeping: ', ruleSelectorList)
selectors.add(ruleSelectorList)
selectorNodeMap.set(rule.prelude, ruleSelectorList)
return true
list.prevUntil(item.prev, function(rule) {
if (rule.type === 'Atrule') {
if (rule.name === 'import' || rule.name === 'charset') {
return;
}
}
this.root.firstAtrulesAllowed = false;
list.remove(item);
return true;
}, this);
break;
default:
var name = resolveKeyword(node.name).basename;
if (name === 'keyframes' ||
name === 'media' ||
name === 'supports') {
// drop at-rule with no prelude
if (hasNoChildren(node.prelude) || hasNoChildren(node.block)) {
list.remove(item);
}
}
}
};
enter: (atrule, atruleItem, atruleList) => {
if (csstree.keyword(atrule.name).basename !== 'font-face') {
return
}
let hasSrc = false
let used = true
csstree.walk(atrule, {
visit: 'Declaration',
enter: declaration => {
const name = csstree.property(declaration.property).name
if (name === 'font-family') {
const familyName = decodeFontName(declaration.value)
// was this @font-face used?
if (!fontNameValues.has(familyName)) {
function addRuleToMap(map, item, list, single) {
var node = item.data;
var name = resolveKeyword(node.name).basename;
var id = node.name.toLowerCase() + '/' + (node.prelude ? node.prelude.id : null);
if (!hasOwnProperty.call(map, name)) {
map[name] = Object.create(null);
}
if (single) {
delete map[name][id];
}
if (!hasOwnProperty.call(map[name], id)) {
map[name][id] = new List();
}
map[name][id].append(list.remove(item));
}