MCPcopy Index your code
hub / github.com/css/csso / processRule

Function processRule

lib/restructure/6-restructBlock.js:220–276  ·  view source on GitHub ↗
(rule, item, list, props, fingerprints)

Source from the content-addressed store, hash-verified

218}
219
220function processRule(rule, item, list, props, fingerprints) {
221 const declarations = rule.block.children;
222
223 declarations.forEachRight(function(declaration, declarationItem) {
224 const { property } = declaration;
225 const fingerprint = getPropertyFingerprint(property, declaration, fingerprints);
226 const prev = props[fingerprint];
227
228 if (prev && !dontRestructure.has(property)) {
229 if (declaration.important && !prev.item.data.important) {
230 props[fingerprint] = {
231 block: declarations,
232 item: declarationItem
233 };
234
235 prev.block.remove(prev.item);
236
237 // TODO: use it when we can refer to several points in source
238 // declaration.loc = {
239 // primary: declaration.loc,
240 // merged: prev.item.data.loc
241 // };
242 } else {
243 declarations.remove(declarationItem);
244
245 // TODO: use it when we can refer to several points in source
246 // prev.item.data.loc = {
247 // primary: prev.item.data.loc,
248 // merged: declaration.loc
249 // };
250 }
251 } else {
252 const prev = needless(props, declaration, fingerprints);
253
254 if (prev) {
255 declarations.remove(declarationItem);
256
257 // TODO: use it when we can refer to several points in source
258 // prev.item.data.loc = {
259 // primary: prev.item.data.loc,
260 // merged: declaration.loc
261 // };
262 } else {
263 declaration.fingerprint = fingerprint;
264
265 props[fingerprint] = {
266 block: declarations,
267 item: declarationItem
268 };
269 }
270 }
271 });
272
273 if (declarations.isEmpty) {
274 list.remove(item);
275 }
276}
277

Callers

nothing calls this directly

Calls 2

getPropertyFingerprintFunction · 0.85
needlessFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…