sass / dart-sass

The reference implementation of Sass, written in Dart.
https://sass-lang.com/dart-sass
MIT License
3.9k stars 351 forks source link

Deprecate function and mixin names beginning with `--` #2230

Closed nex3 closed 4 months ago

nex3 commented 4 months ago

See #2197 See sass/sass#3854 See sass/sass-spec#1982 [skip sass-embedded]

WebMechanic commented 4 months ago

Hello,

I updated to 1.77.0 and noticed this also affects mixins starting with double underscores such as @mixin __fubar() and their @include __fubar().

If this is intended it should probably be mentioned in the documentation

We only had a couple of old mixins using the __ prefix to mark them as "private". No big deal as the warning in the console was very helpful.

Bye.

Goodwine commented 4 months ago

It was intended. Underscores and hyphens are equivalent in Sass identifiers. We assume users are familiar with that fact, but I understand it may not be obvious.

From the docs:

Mixin names, like all Sass identifiers, treat hyphens and underscores as identical. This means that reset-list and reset_list both refer to the same mixin.

https://sass-lang.com/documentation/at-rules/mixin/

WebMechanic commented 4 months ago

Thanks, indeed not so obvious :-) From this example with the inline hyphens and underscores, I had never deduced that this also applies to prefixes which most languages handle very differently -- except CSS and as I learned now, Sass. It's always these "little things" that cause confusion :-)

nex3 commented 3 months ago

I think @WebMechanic is right that this is a bug. The spec is ambiguous here, and there's not a strong reason for us to forbid functions from being written and referenced with double leading underscores.