Skip to content

Commit 6dd49be

Browse files
committed
fix: Function with dot inside name
1 parent 0357c82 commit 6dd49be

File tree

4 files changed

+87
-2
lines changed

4 files changed

+87
-2
lines changed

lib/nodes/Func.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ class Func extends Container {
123123

124124
// fixes #92
125125
// eslint-disable-next-line no-useless-escape
126-
if (!reFunctions.test(node.name) && !/^[a-zA-Z\-]+$/.test(node.name)) {
126+
if (!reFunctions.test(node.name) && !/^[a-zA-Z\-\.]+$/.test(node.name)) {
127127
const nameTokens = getTokens(node.name);
128128
tokens.unshift(...nameTokens, brackets);
129129
parser.back(tokens);

test/fixtures/func.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ module.exports = {
4747
'1em/var(--line-height)',
4848
'local(foo),local(bar)',
4949
'bat-man(#000)',
50-
'conic-gradient()'
50+
'conic-gradient()',
51+
'color.red(#6b717f)'
5152
],
5253

5354
throws: ['url( /gfx/img/bg.jpg ']

test/snapshots/func.test.js.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1871,6 +1871,90 @@ Generated by [AVA](https://avajs.dev).
18711871
},
18721872
]
18731873

1874+
## color.red(#6b717f)
1875+
1876+
> Snapshot 1
1877+
1878+
'color.red(#6b717f)'
1879+
1880+
> Snapshot 2
1881+
1882+
'color.red(#6b717f)'
1883+
1884+
> Snapshot 3
1885+
1886+
[
1887+
Func {
1888+
isColor: false,
1889+
isVar: false,
1890+
name: 'color.red',
1891+
nodes: [
1892+
Word {
1893+
isColor: true,
1894+
isHex: true,
1895+
isUrl: false,
1896+
isVariable: false,
1897+
parent: [Circular],
1898+
raws: {
1899+
after: '',
1900+
before: '',
1901+
},
1902+
source: {
1903+
end: {
1904+
column: 1,
1905+
line: 1,
1906+
offset: 0,
1907+
},
1908+
input: Input {
1909+
css: '#6b717f',
1910+
hasBOM: false,
1911+
id: '<input css 1>',
1912+
[Symbol(fromOffset cache)]: [
1913+
0,
1914+
],
1915+
},
1916+
start: {
1917+
column: 1,
1918+
line: 1,
1919+
offset: 0,
1920+
},
1921+
},
1922+
type: 'word',
1923+
value: '#6b717f',
1924+
[Symbol(isClean)]: false,
1925+
},
1926+
],
1927+
params: '(#6b717f)',
1928+
raws: {
1929+
after: '',
1930+
before: '',
1931+
semicolon: false,
1932+
},
1933+
source: {
1934+
end: {
1935+
column: 10,
1936+
line: 1,
1937+
offset: 9,
1938+
},
1939+
input: Input {
1940+
css: 'color.red(#6b717f)',
1941+
hasBOM: false,
1942+
id: '<input css 1>',
1943+
[Symbol(fromOffset cache)]: [
1944+
0,
1945+
],
1946+
},
1947+
start: {
1948+
column: 1,
1949+
line: 1,
1950+
offset: 0,
1951+
},
1952+
},
1953+
type: 'func',
1954+
[Symbol(isClean)]: false,
1955+
},
1956+
]
1957+
18741958
## conic-gradient()
18751959

18761960
> Snapshot 1

test/snapshots/func.test.js.snap

318 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)