MCPcopy
hub / github.com/css/csso / processRule

Function processRule

lib/restructure/4-restructShorthand.js:328–373  ·  view source on GitHub ↗
(rule, shorts, shortDeclarations, lastShortSelector)

Source from the content-addressed store, hash-verified

326}
327
328function processRule(rule, shorts, shortDeclarations, lastShortSelector) {
329 const declarations = rule.block.children;
330 const selector = rule.prelude.children.first.id;
331
332 rule.block.children.forEachRight(function(declaration, item) {
333 const property = declaration.property;
334
335 if (!MAIN_PROPERTY.hasOwnProperty(property)) {
336 return;
337 }
338
339 const key = MAIN_PROPERTY[property];
340 let shorthand;
341 let operation;
342
343 if (!lastShortSelector || selector === lastShortSelector) {
344 if (key in shorts) {
345 operation = REMOVE;
346 shorthand = shorts[key];
347 }
348 }
349
350 if (!shorthand || !shorthand.add(property, declaration)) {
351 operation = REPLACE;
352 shorthand = new TRBL(key);
353
354 // if can't parse value ignore it and break shorthand children
355 if (!shorthand.add(property, declaration)) {
356 lastShortSelector = null;
357 return;
358 }
359 }
360
361 shorts[key] = shorthand;
362 shortDeclarations.push({
363 operation,
364 block: declarations,
365 item,
366 shorthand
367 });
368
369 lastShortSelector = selector;
370 });
371
372 return lastShortSelector;
373}
374
375function processShorthands(shortDeclarations, markDeclaration) {
376 shortDeclarations.forEach(function(item) {

Callers

nothing calls this directly

Calls 1

addMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…