Reference notation syntax #55162
Replies: 4 comments 5 replies
-
I think a property like
And then clarify in the docs, any limitations for values accepted |
Beta Was this translation helpful? Give feedback.
-
At this moment, I would stick with the dot With I am unfamiliar with PHP/WordPress errors but, could we throw a descriptive error explaining that it is not JS when users include not supported syntax inside a directive? |
Beta Was this translation helpful? Give feedback.
-
Thank you @luisherranz for opening this discussion. For me, the dot notation definitely caused some confusion while reading the docs and your mention of the “path-notation” felt like it much more clearly communicated the intention of the API. However, after giving it some thoughts, I personally think it's perhaps for the best to keep the dot notation. You mention that you don't plan to ship any other features besides the negation These are all excellent considerations, however, I now feel that perhaps keeping the dot notation keeps these things a bit more open for posterity. These are early days of the Interactivity API and, though you certainly have much more context and insight than I do, I think it'd be really hard to predict where it would go from here on out into the years. Keeping the dot notation, we make it much easier for our children and grandchildren (🤭) to expand its capabilities into parsing more expressions as requested by some of the commenters and should the need arise, without breaking backwards compatibility, or making the parser too complex. This might never happen, but given our commitment to backwards compatibility, I think it'd be quite forward thinking to design something that's more open to the unknowns of the future, the decisions of the community and also possible leaps and improvements of the web platform itself. Given this, I think focusing on being clear in the docs should solve the problem I had, and perhaps trying to catch those errors like it was mentioned above, would make sure that people who only skimmed the docs or worked on hacking away something by example will get guidance and the least frustration possible. |
Beta Was this translation helpful? Give feedback.
-
I'm going to close this as resolved because there seems to be a general consensus on keeping the dot notation, but feel free to reopen it if you feel like this should be discussed further. |
Beta Was this translation helpful? Give feedback.
-
Right now, we are using the dot notation (
.
) to reference specific properties of the store in the directive values:We also support a negation prefix (
!
) because that's very easy to implement and very convenient at the same time:But when a developer sees
!state.isVisible
, it's impossible to infer that this is not JavaScript.Thanks to the new
store()
API, we will deviate a little bit from JavaScript syntax, but only when using non-default namespaces:It helps, but referencing non-default namespaces will be rare.
There's also the question of whether we want to add more logic apart from
!
or not, like==
:I'm not in favor of doing that, but I wanted to mention it anyway. I think it will lead to more confusion (because we will never be able to match people's expectations), and it will increase the size of the runtime.
In the past, we briefly discussed replacing the
.
notation with something else, for example slashes (/
):It feels a bit weird to me at this moment, but it's true that all changes feel like that until you get used to them (it happened with the
data-
and the--
) 😄🤷♂️It's also weird when you mix it with the negation
!
operator:Although when mixed with the non-default namespace doesn't look that bad to me:
So what are your thoughts:
.
notation because it's nice and focus our efforts on making it very clear that it's not JavaScript in the documentation?cc: @juanmaguitar, @ryanwelcher, @DAreRodz, @SantosGuillamot, @sunyatasattva
Beta Was this translation helpful? Give feedback.
All reactions