diff --git a/lib/parser.js b/lib/parser.js index 7652d98..fb21b86 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -463,7 +463,7 @@ module.exports = class Parser { if (node.constructor.name === 'Word') { node.isHex = /^#(.+)/.test(value); - node.isColor = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.test(value); + node.isColor = /^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(value); } else { this.cache.push(this.current); diff --git a/test/word.js b/test/word.js index 7caa784..b94839e 100644 --- a/test/word.js +++ b/test/word.js @@ -67,6 +67,15 @@ describe('Parser → Word', () => { expected: [ { type: 'word', value: '-webkit-transition' } ] + }, + { + it: 'should parse hex colors', + test: '#123 #abcdef #a2b3c4d5', + expected: [ + { type: 'word', value: '#123', isHex: true, isColor: true }, + { type: 'word', value: '#abcdef', isHex: true, isColor: true }, + { type: 'word', value: '#a2b3c4d5', isHex: true, isColor: true } + ] } ];