Skip to content

Commit 6db7891

Browse files
author
Bart Veneman
committed
make color formats have locations too
1 parent 85c1115 commit 6db7891

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/index.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { analyzeAnimation } from './values/animations.js'
1010
import { isAstVendorPrefixed } from './values/vendor-prefix.js'
1111
import { ContextCollection } from './context-collection.js'
1212
import { Collection } from './collection.js'
13-
import { CountableCollection } from './countable-collection.js'
1413
import { AggregateCollection } from './aggregate-collection.js'
1514
import { strEquals, startsWith, endsWith } from './string-utils.js'
1615
import { hasVendorPrefix } from './vendor-prefix.js'
@@ -54,7 +53,7 @@ function analyze(css, options = {}) {
5453
// Stylesheet
5554
let totalComments = 0
5655
let commentsSize = 0
57-
let embeds = new CountableCollection()
56+
let embeds = new Collection({ useLocations })
5857
let embedSize = 0
5958
let embedTypes = {
6059
total: 0,
@@ -147,9 +146,8 @@ function analyze(css, options = {}) {
147146
let timingFunctions = new Collection({ useLocations })
148147
let durations = new Collection({ useLocations })
149148
let colors = new ContextCollection({ useLocations })
150-
let colorFormats = new CountableCollection()
151-
let units = new ContextCollection()
152-
let gradients = new CountableCollection()
149+
let colorFormats = new Collection({ useLocations })
150+
let units = new ContextCollection({ useLocations })
153151

154152
walk(ast, function (node) {
155153
switch (node.type) {
@@ -330,7 +328,7 @@ function analyze(css, options = {}) {
330328
}
331329

332330
// @deprecated
333-
embeds.push(embed)
331+
embeds.push(embed, node.loc)
334332
}
335333
break
336334
}
@@ -442,7 +440,7 @@ function analyze(css, options = {}) {
442440
hexLength = hexLength - 2
443441
}
444442
colors.push('#' + valueNode.value, property, valueNode.loc)
445-
colorFormats.push(`hex` + hexLength)
443+
colorFormats.push(`hex` + hexLength, valueNode.loc)
446444

447445
return this.skip
448446
}
@@ -457,21 +455,21 @@ function analyze(css, options = {}) {
457455
if (namedColors.has(nodeName)) {
458456
let stringified = stringifyNode(valueNode)
459457
colors.push(stringified, property, valueNode.loc)
460-
colorFormats.push('named')
458+
colorFormats.push('named', valueNode.loc)
461459
return
462460
}
463461

464462
if (colorKeywords.has(nodeName)) {
465463
let stringified = stringifyNode(valueNode)
466464
colors.push(stringified, property, valueNode.loc)
467-
colorFormats.push(nodeName.toLowerCase())
465+
colorFormats.push(nodeName.toLowerCase(), valueNode.loc)
468466
return
469467
}
470468

471469
if (systemColors.has(nodeName)) {
472470
let stringified = stringifyNode(valueNode)
473471
colors.push(stringified, property, valueNode.loc)
474-
colorFormats.push('system')
472+
colorFormats.push('system', valueNode.loc)
475473
return
476474
}
477475
return this.skip

0 commit comments

Comments
 (0)