Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function localizeDecl(decl, context) {
var valuesNode = Tokenizer.parseValues(decl.value);
var localizeName = /animation(-name)?$/.test(decl.prop);
var newValuesNode = Object.create(valuesNode);
newValuesNode.nodes = valuesNode.nodes.map(function(valueNode) {
var subContext = {
options: context.options,
global: context.global,
localizeNextItem: localizeName && !context.global
};
return localizeDeclValue(valueNode, subContext);
});
decl.value = Tokenizer.stringifyValues(newValuesNode);
}
css.walkAtRules(/^import$/i, function(rule) {
var values = Tokenizer.parseValues(rule.params);
var url = values.nodes[0].nodes[0];
if(url && url.type === "url") {
url = url.url;
} else if(url && url.type === "string") {
url = url.value;
} else throw rule.error("Unexpected format " + rule.params);
if (!url.replace(/\s/g, '').length) {
return;
}
values.nodes[0].nodes.shift();
var mediaQuery = Tokenizer.stringifyValues(values);
if(loaderUtils.isUrlRequest(url, options.root)) {
url = loaderUtils.urlToRequest(url, options.root);
}
css.walkDecls(function(decl) {
var values = Tokenizer.parseValues(decl.value);
values.nodes.forEach(function(value) {
value.nodes.forEach(processNode);
});
decl.value = Tokenizer.stringifyValues(values);
});
css.walkAtRules(function(atrule) {
css.walkAtRules(/^import$/i, function(rule) {
var values = Tokenizer.parseValues(rule.params);
var url = values.nodes[0].nodes[0];
if(url && url.type === "url") {
url = url.url;
} else if(url && url.type === "string") {
url = url.value;
} else throw rule.error("Unexpected format " + rule.params);
if (!url.replace(/\s/g, '').length) {
return;
}
values.nodes[0].nodes.shift();
var mediaQuery = Tokenizer.stringifyValues(values);
if(loaderUtils.isUrlRequest(url, options.root) && options.mode === "global") {
url = loaderUtils.urlToRequest(url, options.root);
}
importItems.push({
url: url,
css.walkAtRules(/^import$/i, function(rule) {
var values = Tokenizer.parseValues(rule.params);
var url = values.nodes[0].nodes[0];
if(url && url.type === "url") {
url = url.url;
} else if(url && url.type === "string") {
url = url.value;
} else throw rule.error("Unexpected format " + rule.params);
if (!url.replace(/\s/g, '').length) {
return;
}
values.nodes[0].nodes.shift();
var mediaQuery = Tokenizer.stringifyValues(values);
if(loaderUtils.isUrlRequest(url, options.root) && options.mode === "global") {
url = loaderUtils.urlToRequest(url, options.root);
}
importItems.push({
url: url,
function getDependencyIdentifiersFromDeclarationValue(value) {
const node = css_selector_tokenizer_1.parseValues(value);
const accum = [];
findUrlsInNode(node, accum);
return accum;
}
exports.getDependencyIdentifiersFromDeclarationValue = getDependencyIdentifiersFromDeclarationValue;
css.walkAtRules(/^import$/i, function(rule) {
var values = Tokenizer.parseValues(rule.params);
var url = values.nodes[0].nodes[0];
if(url && url.type === "url") {
url = url.url;
} else if(url && url.type === "string") {
url = url.value;
} else throw rule.error("Unexpected format " + rule.params);
if (!url.replace(/\s/g, '').length) {
return;
}
values.nodes[0].nodes.shift();
var mediaQuery = Tokenizer.stringifyValues(values);
if(loaderUtils.isUrlRequest(url, options.root) && options.mode === "global") {
url = loaderUtils.urlToRequest(url, options.root);
}
importItems.push({
url: url,
css.eachAtRule("import", function(rule) {
var values = Tokenizer.parseValues(rule.params);
var url = values.nodes[0].nodes[0];
if(url.type === "url") {
url = url.url;
} else if(url.type === "string") {
url = url.value;
} else throw rule.error("Unexpected format" + rule.params);
values.nodes[0].nodes.shift();
var mediaQuery = Tokenizer.stringifyValues(values);
if(loaderUtils.isUrlRequest(url, options.root) && options.mode === "global") {
url = loaderUtils.urlToRequest(url, options.root);
}
importItems.push({
url: url,
mediaQuery: mediaQuery
});
rule.removeSelf();
export function processDeclarationUrls(
decl: postcss.Declaration,
onUrl: OnUrlCallback,
transform: boolean
) {
const ast = parseValues(decl.value);
ast.nodes.forEach((node: ParsedValue) => {
node.nodes!.forEach((node: ParsedValue) => findUrls(node, onUrl));
});
if (transform) {
decl.value = stringifyValues(ast);
}
}
export function getDependencyIdentifiersFromDeclarationValue(string) {
const node = cssSelectorTokenizer.parseValues(string);
const accum = [];
findUrlsInNode(node, accum);
return accum;
}