-
Notifications
You must be signed in to change notification settings - Fork 159
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
Revisiting div class/id shorthand #172
Comments
Good idea! The only issue would be the interaction with named attributes. Currently class/id shorthands and named attributes can be interleaved in an arbitrary way, so e.g. div contenteditable? #unique-id dir="rtl" .awesome-class {} is valid syntax. If we do the obvious thing and allow omitting the element name with no other changes, then contenteditable? #unique-id dir="rtl" .awesome-class {} would be valid syntax. That's not ambiguous but it could be confusing. I think an easy solution would be to say that any classes/ids must come before named attributes. That eliminates the confusing example I gave above, and I think it was an accident that the interleaving was allowed in the first place. What do you think @zth0? If you're happy with this tweak then I'm happy to take a PR 🙂 |
The way I was planning to go about it would have been to only allow omitting element name if only if the first attribute of the element is a class or id shorthand such that .awesome-class contenteditable? dir="rtl" #unique-id {}
#unique-id contenteditable? dir="rtl" .awesome-class {} is valid syntax (still allowing any order of class and id attrs beyond the implicit div) but contenteditable? #unique-id dir="rtl" .awesome-class {} isn't (which prevents it from being confusing.) I'm not sure if you meant allowing omitting element name even without any attrs but I'd prefer not to go about it this way as I think this causes more breakage than is necessary. I'm not sure if this matches what you were thinking but I think that going about it this way instead would prevent this from breaking any old code and should be simpler to implement. |
Opened PR #173 with my suggested implementation, let me know what you think and if I missed anything or you would rather your idea. |
Oh I forgot about plain blocks. That makes sense to me! |
BTW, issues should stay open until the PR has been merged. |
As of #137 (which as far as I can tell fixes the ambiguity issue outlined in #35 and #28) I don't see any reason why the shorthand syntax for classes and ids can't be expanded to allow the case with no element tag such as
.awesome-class#unique-id
instead ofdiv.awesome-class#unique-id
.I'd be happy to look into making a PR to add this functionality if you wouldn't be apposed to this syntax now.
The text was updated successfully, but these errors were encountered: