-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
feat: new attribute scope style strategy #7893
Conversation
🦋 Changeset detectedLatest commit: d0f5d74 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 |
869650a
to
b187935
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.
This PR is blocked because it contains a minor
changeset. A reviewer will merge this at the next release if approved.
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.
Maybe we can also release this in 2.10? But I'm fine either ways.
I think we're still bikeshedding this. If there's resolution before 2.10 we can ship it, otherwise 3.0 is fine. |
160bcb8
to
9c9882d
Compare
1a7439e
to
d9538f1
Compare
for (const [key] of Object.entries(classes[0].attribs)) { | ||
if (/^data-astro-cid-[A-Za-z0-9-]+/.test(key)) { | ||
// Ema: this is ugly, but for reasons that I don't want to explore, cheerio | ||
// lower case the hash of the attribute | ||
scopedAttribute = key | ||
.toUpperCase() | ||
.replace('data-astro-cid-'.toUpperCase(), 'data-astro-cid-'); | ||
} | ||
} |
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.
IIRC the HTML spec have attributes all lowercased by default, which is why it uses kebab-case. Maybe we should consider making our hashes lower-case 🤔
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.
since this is mostly for aesthetically I agree here too, lowercase looks cleaner since the data- part is lower (subjective opinion of course).
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.
Although this change doesn't change the hash does it? In which case I don't think that's a blocker for this issue.
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.
That’s a very good point. In the browser they’ll be normalized to be all lowercase anyway, so we might as well generate them like that.
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.
Thank you. Worth considering for a next PR then :)
ade8869
to
9359ab2
Compare
28c2fe5
to
22e8bd1
Compare
6e3df39
to
d0f5d74
Compare
Changes
This adds a new scope style strategy called
attribute
.When enabled, styles are emitted using the
data-*
attributes.This PR changes the default value of
scopedStyleStrategy
, its new value is now"attribute"
.Testing
Added new test cases and updated the current ones.
Docs
/cc @withastro/maintainers-docs for feedback!