Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('parses CSS as PostCSS AST', function () {
var css = 'a{a:a}';
var ast = postcss.parse(css);
parsed = internal.parse(ast);
});
test('converts declarations to array', t => {
let root = parse('color: black; color: rgba(0,0,0,.5); color: #000.5;');
t.deepEqual(postcssJS.objectify(root), {
color: [
'black',
'rgba(0,0,0,.5)',
'#000.5'
]
});
});
it('svgpack.css', function (done) {
var content = readFileSync(dest + '/' + name + '.css')
var className = postcss.parse(content).nodes[0].selector
assert.equal(className, '.icon')
done()
})
function processSource(source: string, options: postcss.ProcessOptions = {}) {
return process(postcss.parse(source, options));
}
function processFormattersFromSource(source: string, options: postcss.ProcessOptions = {}) {
const parsed = postcss.parse(source, options).nodes![0] as postcss.Rule;
const formatters = parsed.nodes!.map((decl: any) => {
return processFormatters(decl).stylable.formatters;
});
return formatters;
}
function cssToObject(styles) {
check(styles, Match.OneOf(String, null, undefined, void 0));
const parsedStyle = postcss.parse(styles || baseStyles);
const styleObject = postcssJS.objectify(parsedStyle);
return styleObject;
}
CSS2Modernizr.prototype.usage = function () {
var regex, css, results, modules;
results = [];
regex = new RegExp("\\." + this.prefix + "(no-)?(" + _.keys(tests).join('|').toLowerCase() + ")", "g");
css = postcss.parse(this.css);
css.eachRule(function (rule) {
_.forEach(rule.selectors, function(selector) {
var found, key, index;
found = regex.exec(selector);
if (found) {
key = found[2];
index = _.findKey(results, { 'name': key });
if (index) {
results[index]["count"]++;
} else {
results.push({
'name': key,
'count': 1
});
}
}
const styleToObject = styleText => {
const styleObject = postcssJs.objectify(postcss.parse(styleText))
return JSON5.stringify(styleObject)
}
.then(text => {
const ast = postcss.parse(text);
const outcome = postcss_ast_dependencies_1.postcssAstDependencies(ast);
const scan = new FileScan(file);
scan.identifiers = outcome.identifiers;
return scan;
});
}
export default (
inputCss: string,
allowCombinators = false
): { root: Root; propTypes: PropTypes } => {
const transformedInput = inputCss.replace(/(\[\s*)@(\w)/g, `$1cssta|$2`);
const root = postcss.parse(transformedInput);
iterateChildren(root, nestNode);
const propTypes = {};
const validateAndTransformSelectors = selectorParser(container => {
container.each(selector => {
if (selector.type !== "selector") {
throw new Error("Expected selector");
}
let didScopeNode = false;
selector.walk(node => {
if (node.type === "combinator" && !allowCombinators) {
throw new Error("Invalid use of combinator in selector");
} else if (node.type === "nesting") {