Kozea/tinycss2

@import url("resource") is parsed to FunctionBlock instead of URLToken in 1.1.0

ikseek opened this issue · 1 comments

Here is reproducer that works with 1.0.2 and fails in 1.1.0

from tinycss2 import parse_stylesheet_bytes
from tinycss2.ast import AtRule, WhitespaceToken, URLToken

rules, enc = parse_stylesheet_bytes(b'@include url("1.css");')
import_rule = rules[0]
assert type(import_rule) is AtRule
assert type(import_rule.prelude[0]) is WhitespaceToken
assert type(import_rule.prelude[1]) is URLToken
liZe commented

Hello!

It has changed in tinycss2 1.1.0, because that’s actually what the spec defines since a change introduced in 2014. The url-token is a token only used for url(…) without quotes. With quotes, it’s a simple function. The url concept is defined at a higher level.

The docstring of URLToken has not been changed, and that’s something that should be fixed.