matthewp / corset

Declarative data bindings, bring your own backend.

Home Page:https://corset.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Identifiers vs. strings

matthewp opened this issue · comments

Corset treats identifiers and strings as interchangeable. The only difference is what characters are allowed; identifiers only allow [a-zA-Z] (note this is probably not to CSS spec and should be fixed).

The use case here is aesthetics and the belief that there wouldn't be builtin identifiers in Corset.

button {
  event: click var(--increment);
}

vs.

button {
  event: "click" var(--increment);
}

However, @propjockey provided a reason for why we might want builtin identifiers. This would be nice:

.profile:not(.editing) {
  text: initial;
}

I think there's a choice here of one of these:

  1. Force using strings where identifiers are used now.
    • Maybe this would be more intuitive anyways?
  2. Have reserved words like initial but otherwise allow identifiers as strings.
    • Hard to predict ahead of time what we need to reserve.
  3. Keep identifiers as strings and use functions for things like initial. initial().
    • Might be unexpected coming from CSS.
  4. Allow identifiers as strings only in certain properties. For example could we allow them as the event name, without allowing them generally?

This is no longer necessary. I discovered that CSS itself has <custom-ident> (https://developer.mozilla.org/en-US/docs/Web/CSS/custom-ident) and it is more prevalent than I realized. That means that special identifiers for things like initial are ok; you can always use a string if you want the string value.