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

Backwards compatible fix for --camelCase css vars in style attribute #6268

Merged
merged 2 commits into from
Feb 17, 2023

Conversation

natemoo-re
Copy link
Member

@natemoo-re natemoo-re commented Feb 16, 2023

Changes

---
const myValue = "red"
---
<!-- input -->
<div style={{ "--myValue": myValue }} />

<!-- output (before) -->
<div style="--my-value:red"></div>

<!-- output (now, this PR) -->
<div style="--my-value:var(--myValue);--myValue:red"></div>

Testing

Tested manually, small enough that we don't have tests

Docs

Related to withastro/docs#1539
/cc @withastro/maintainers-docs for feedback!

@changeset-bot
Copy link

changeset-bot bot commented Feb 16, 2023

🦋 Changeset detected

Latest commit: 94101f2

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Feb 16, 2023
Copy link
Member

@delucis delucis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Really smart way to handle this.

Copy link
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<div style="--my-value:var(--myValue);--myValue:red"></div>

Looks like the snake case var accesses the camelCase var that is declared later, but I tested this and it still worked fine too 👍 LGTM

@natemoo-re natemoo-re merged commit 933c651 into main Feb 17, 2023
@natemoo-re natemoo-re deleted the fix/define-vars-case branch February 17, 2023 17:04
@astrobot-houston astrobot-houston mentioned this pull request Feb 17, 2023
liruifengv pushed a commit to liruifengv/astro that referenced this pull request Feb 18, 2023
…ute (withastro#6268)

* fix(withastro#6264): backward-compat fix for camelCase css vars in style

* chore: add changeset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Camel case CSS variables transformed to kebab case when used in style object
3 participants