[csswg-drafts] [css-syntax-3] Consume an ident-like token algorithm differs for function tokens that start with `url` (#8280)

romainmenke has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-syntax-3] Consume an ident-like token algorithm differs for function tokens that start with `url` ==
https://www.w3.org/TR/css-syntax-3/#consume-ident-like-token

1. If string’s value is an [ASCII case-insensitive](https://infra.spec.whatwg.org/#ascii-case-insensitive) match for "url", and the [next input code point](https://www.w3.org/TR/css-syntax-3/#next-input-code-point) is U+0028 LEFT PARENTHESIS ((), consume it
2. While the next two input code points are [whitespace](https://www.w3.org/TR/css-syntax-3/#whitespace), consume the next input code point.
3. 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>](https://www.w3.org/TR/css-syntax-3/#typedef-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"` :

```
url(  "foo")
```

Follow this algorithm this 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('`

_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.

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/8280 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Tuesday, 3 January 2023 22:04:39 UTC