(rule, shorts, shortDeclarations, lastShortSelector)
| 326 | } |
| 327 | |
| 328 | function 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 | |
| 375 | function processShorthands(shortDeclarations, markDeclaration) { |
| 376 | shortDeclarations.forEach(function(item) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…