https://www.w3.org/TR/css-syntax-3/#consume-ident-like-token
- If string’s value is an ASCII case-insensitive match for "url", and the next input code point is U+0028 LEFT PARENTHESIS ((), consume it
- While the next two input code points are whitespace, consume the next input code point.
- If the next one or two input code points are U+0022 QUOTATION MARK ("), U+0027 APOSTROPHE ('), or whitespace followed by U+0022 QUOTATION MARK (") or U+0027 APOSTROPHE ('), then create a
<function-token> with its value set to string and return it.
This algorithm indicates that whitespace characters are consumed and "attributed" to the function token.
For example two spaces before "foo" :
Following this algorithm it tokenizes as :
['function-token', 'url( ', 0, 4, { value: 'url' }],
['whitespace-token', ' ', 5, 5, undefined],
['string-token', '"foo"', 6, 10, { value: 'foo' }],
[')-token', ')', 11, 11, undefined],
['EOF-token', '', -1, -1, undefined],
While any other function name tokenizes as :
['function-token', 'not-url(', 0, 7, { value: 'not-url' }],
['whitespace-token', ' ', 8, 9, undefined],
['string-token', '"foo"', 10, 14, { value: 'foo' }],
[')-token', ')', 15, 15, undefined],
['EOF-token', '', -1, -1, undefined],
The raw values of the function tokens are :
'url( ' (notice the trailing space)
'not-url('
The raw values of the whitespace tokens are :
Sorry for the technical notation, when I tried to write it differently it became more ambiguous
First of all I am unsure if I read the specification correctly.
I don't know if I am tokenizing these correctly or if I have a bug.
I don't think it affects parsing because the meaningful values are not affected by consuming whitespace in this way.
This might be relevant in developer tooling where it is important to tokenize and serialize without mutations.
https://www.w3.org/TR/css-syntax-3/#consume-ident-like-token
<function-token>with its value set to string and return it.This algorithm indicates that whitespace characters are consumed and "attributed" to the function token.
For example two spaces before
"foo":Following this algorithm it tokenizes as :
While any other function name tokenizes as :
The raw values of the function tokens are :
'url( '(notice the trailing space)'not-url('The raw values of the whitespace tokens are :
' '' 'Sorry for the technical notation, when I tried to write it differently it became more ambiguous
First of all I am unsure if I read the specification correctly.
I don't know if I am tokenizing these correctly or if I have a bug.
I don't think it affects parsing because the meaningful values are not affected by consuming whitespace in this way.
This might be relevant in developer tooling where it is important to tokenize and serialize without mutations.