Less case modifications for keys#1030
Less case modifications for keys#1030gazpachoking wants to merge 3 commits intostarfederation:developfrom
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.
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.
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.
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.
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. |
|
This has been merged for the RC.6 release, thanks! |
|
Released in v1.0.0-RC.6, thanks @gazpachoking! |
New try at #1025
Main ideas:
Things I actually think are bad with the current implementation (that this PR fixes):
data-signals-letter4numberends 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.kebabif that was your intention. kebab in this PR just keeps literally whatever you had in the attribute.data-signals-1fooJust 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-vardata-signals-my--doubledash__case.kebabThings this will 'break':