Skip to content
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

Support raw property on returned declarations in visitors #385

Merged
merged 5 commits into from
Jan 7, 2023

Conversation

devongovett
Copy link
Member

@devongovett devongovett commented Jan 7, 2023

This enables a raw property to be provided instead of value when returning declarations from JS visitors. This will be parsed as a CSS value for the given property name as if it were written in a CSS file. This should make it easier to return known CSS values rather than constructing the full AST for them manually.

{
  property: 'background',
  raw: 'yellow url(foo.png)'
}

To make this work, we needed an into_owned() method for all values with lifetimes so that we can parse the raw string and store the result in the AST without borrowing from it. This will be useful for other things as well, like substituting variable values. It is derived by a proc macro behind the "into_owned" feature flag.

Another option would have been exposing a parseProperty function that would return a parsed AST from a string, but this would require more back and forth between JS and native which can have some overhead. Allowing raw CSS strings to be returned avoids this.

@devongovett devongovett merged commit c13f441 into master Jan 7, 2023
@devongovett devongovett deleted the to_static branch January 7, 2023 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant