Skip to content

Commit

Permalink
Fix extractReferencedCustomPropertyNames when there's a default value
Browse files Browse the repository at this point in the history
  • Loading branch information
papandreou committed Jul 9, 2022
1 parent 5028f72 commit 5063755
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/extractReferencedCustomPropertyNames.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function extractReferencedCustomPropertyNames(cssValue) {
if (
node.type === 'function' &&
node.value === 'var' &&
node.nodes.length === 1 &&
node.nodes.length >= 1 &&
node.nodes[0].type === 'word' &&
/^--/.test(node.nodes[0].value)
) {
Expand Down
10 changes: 10 additions & 0 deletions test/extractReferencedCustomPropertyNames.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ describe('extractReferencedCustomPropertyNames', function () {
);
});

it('should return the name of a referenced custom property with a default value', function () {
expect(
extractReferencedCustomPropertyNames(
"foo(bar), var(--abc, 'the default'), bla-bla"
),
'to equal',
new Set(['--abc'])
);
});

it('should return the names of multiple referenced custom properties', function () {
expect(
extractReferencedCustomPropertyNames(
Expand Down

0 comments on commit 5063755

Please sign in to comment.