Skip to content

Commit eeff228

Browse files
committed
fix: color names should be case-insensitive. fixes #67
1 parent 130087c commit eeff228

File tree

4 files changed

+80
-2
lines changed

4 files changed

+80
-2
lines changed

lib/nodes/Word.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Word extends Node {
3434

3535
const { lastNode } = parser;
3636
const { value } = lastNode;
37-
lastNode.isColor = colorRegex.test(value) || colorNames.includes(value);
37+
lastNode.isColor = colorRegex.test(value) || colorNames.includes(value.toLowerCase());
3838
lastNode.isHex = hexRegex.test(value);
3939
lastNode.isUrl = isUrl(value);
4040
lastNode.isVariable = Word.testVariable(tokens[0], parser);

test/fixtures/word.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ module.exports = {
1818
'-webkit-transition',
1919
'#fff',
2020
'#123 #f09f #abcdef #a2b3c4d5',
21-
'blanchedalmond'
21+
'blanchedalmond',
22+
'BLANCHEDALMOND',
23+
'blAncHedaLmoNd'
2224
]
2325
};

test/snapshots/word.test.js.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,82 @@ Generated by [AVA](https://ava.li).
664664
},
665665
]
666666

667+
## BLANCHEDALMOND
668+
669+
> Snapshot 1
670+
671+
'BLANCHEDALMOND'
672+
673+
> Snapshot 2
674+
675+
[
676+
Word {
677+
isColor: true,
678+
isHex: false,
679+
isUrl: false,
680+
isVariable: false,
681+
raws: {
682+
after: '',
683+
before: '',
684+
},
685+
source: {
686+
end: {
687+
column: 1,
688+
line: 1,
689+
},
690+
input: Input {
691+
css: 'BLANCHEDALMOND',
692+
hasBOM: false,
693+
id: '<input css 10>',
694+
},
695+
start: {
696+
column: 1,
697+
line: 1,
698+
},
699+
},
700+
type: 'word',
701+
value: 'BLANCHEDALMOND',
702+
},
703+
]
704+
705+
## blAncHedaLmoNd
706+
707+
> Snapshot 1
708+
709+
'blAncHedaLmoNd'
710+
711+
> Snapshot 2
712+
713+
[
714+
Word {
715+
isColor: true,
716+
isHex: false,
717+
isUrl: false,
718+
isVariable: false,
719+
raws: {
720+
after: '',
721+
before: '',
722+
},
723+
source: {
724+
end: {
725+
column: 1,
726+
line: 1,
727+
},
728+
input: Input {
729+
css: 'blAncHedaLmoNd',
730+
hasBOM: false,
731+
id: '<input css 11>',
732+
},
733+
start: {
734+
column: 1,
735+
line: 1,
736+
},
737+
},
738+
type: 'word',
739+
value: 'blAncHedaLmoNd',
740+
},
741+
]
742+
667743
## blanchedalmond
668744

669745
> Snapshot 1

test/snapshots/word.test.js.snap

143 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)