-
-
Notifications
You must be signed in to change notification settings - Fork 75
Use css-tree #234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use css-tree #234
Conversation
7b20db2
to
f091f92
Compare
It would be nice if jsdom only had one CSS parser in its dependency tree. jsdom/jsdom#3910 is trying to replace rrweb-cssom with a better replacement. Maybe jsdom should use csstree instead as well? |
Well, I guess we cannot eliminate some cssom package because that's how we currently implement many objects... https://github.com/jsdom/jsdom/blob/aa52984e863d2722fb8beae757d7ea5568cea1b2/lib/jsdom/level2/style.js#L23-L30 Still, it is a good goal to eventually have just a single parser. Maybe we can just implement the objects from scratch inside jsdom, and delegate the hard parsing/serialization work to csstree. For example, https://drafts.csswg.org/cssom/#the-medialist-interface looks pretty easy to do from scratch as long as you have an algorithm media query parsing and serialization. |
I am aware that a PR to replace rrweb-cssom has been submitted. Apart from that, this PR aims to resolve some inconsistencies with cssstyle. However, what it actually does is parse CSS values using the original CSSStyleDeclaration from NV/CSSOM (now rrweb-cssom).
Ideally, cssstyle should take the place of the CSSStyleDeclaration part, but what happens if we add cssstyle as a dependency to rrweb-cssom? That's why I want to remove rrweb-cssom from cssstyle. CSSTree is a great library, but implementing CSSOM-related things and CSSStyleDeclaration will likely require complex processing from the AST. |
I will give my thoughts on #235 separately. Anyway, I will request a review for this PR. |
Ah, found https://github.com/csstools/postcss-plugins/tree/main/packages/css-syntax-patches-for-csstree |
PR ready |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you remove @csstools/css-syntax-patches-for-csstree
? (Also, when you do add it, we should add a test which depends on that package existing.)
It is useful for cssTree.lexer. |
cssTree.lexer is very powerful and it can probably replace our isValid functions under properties/. |
Changed my mind and decided to implement |
a65f48c
to
2587927
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am a little worried that we only replaced one instance of parseKeyword()
, and left all the existing ones alone. However, I cannot see any obvious cases where this halfway state would cause problems, so I will merge this.
I would love it if you were able to open an issue detailing your plans for replacing more and more parts of this library with css-tree. (Or maybe discussing in #235 is best.)
Could you please release a new version? |
Done. Thank you for your work! |
Switch to CSSTree to improve code quality.
Related wpts:
to-upstream
css/cssom
css/css-color
Fails but this is expected. Need to fix getComputedStyle()