Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Escape handling #133
Fix numerous escaping issues and syntax handling regressions in 3.0.
Note: this PR is a Work-in-Progress. Feedback is welcome, commits are still forthcoming. Details will be added here as they develop.
Strings and identifiers from CSS files are now exposed to the API after unescaping them and API consumers going forward will set property values without containing any escape sequences. This optimizes the majority use-case of using standard CSS syntax and expecting it to Just Work™.
There are special APIs to use for setting values when normal CSS escaping rules are being intentionally broken -- these must be used whenever values are manipulating non-standard syntax. See methods
BREAKING CHANGES: This PR introduces breaking changes. Where possible and likely to add the most value, deprecations have been added. But because it's impossible to know if a string has or hasn't been escaped by the caller, full deprecation handling is hard to achieve without materially making the new APIs worse and then introducing a subsequent deprecation/remove cycle back to the original API but with the new semantics. It's a lot of churn for API consumers, most of whom probably don't need to worry about whether things are escaped at all because they don't have a single escape in their stylesheets. For those users, this change appears as a bug fix (which indeed, it is).
The lexer no longer breaks word tokens apart when an escape sequence is
The lexer does not unescape. This allows the parser to capture the originally authored escape syntax and preserve it during stringification if a selector built from that token is left untouched.
Some AST nodes had support for a
Constructors for all node types expect property values to be unescaped. If the
The parser now sets properties to the escaped value and tracks the unescaped property values in
Notes for Specific Types of Nodes