-
-
Notifications
You must be signed in to change notification settings - Fork 177
Less case modifications for keys #1030
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
base: develop
Are you sure you want to change the base?
Less case modifications for keys #1030
Conversation
if (!el.closest(ignore)) { | ||
for (const key in el.dataset) { | ||
applyAttributePlugin(el, key, el.dataset[key]!) | ||
applyAttributePlugin(el, key.replace(/[A-Z]/g, '-$&').toLowerCase(), el.dataset[key]!) |
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.
Just undo dataset case.
export function modifyCasing(str: string, mods: Modifiers) { | ||
for (const c of mods.get('case') || []) { | ||
export function modifyCasing(str: string, mods: Modifiers, defaultCase: string = 'camel') { | ||
for (const c of mods.get('case') || [defaultCase]) { |
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.
Makes the default case a param so that only one case modifier is applied. Before the default case would be applied no matter what, then the user case applied on top of that.
for (const { name, value } of (newNode as Element).attributes) { | ||
if ( | ||
(oldNode as Element).getAttribute(name) !== value && | ||
!preserveAttrs.includes(kebab(name)) |
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.
Not sure why we are applying kebab case to raw element attribute names here. Perhaps I shouldn't have changed this though because it's not related to my other changes.
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 took this change out. Originally I was trying to remove all the non attribute key uses of the case functions, but I ended up leaving them untouched and creating separate ones for case mods.
b5a5f7c
to
9182afa
Compare
Thanks for the PR, @gazpachoking! We’re planning on switching |
Updating for colons was like a 2 character change, so I went ahead and did that and resolved conflicts. Happy to do it again on top of whatever changes you guys have internally though if things have diverged. |
New try at #1025
Main ideas:
Things I actually think are bad with the current implementation (that this PR fixes):
data-signals-letter4number
ends up capitalizing the first letter after a number. (letter4Number) Very surprising, and no case modifier that can save you at the moment.data-signals-letter-4-number__case.kebab
if that was your intention. kebab in this PR just keeps literally whatever you had in the attribute.data-signals-1foo
Just doesn't work right now. Don't see why it shouldn't.Things that aren't really bad but this fixes anyway:
data-style---css-var
data-signals-my--doubledash__case.kebab
Things this will 'break':