apply rules to do `.foo` vs `["foo"]`
caridy opened this issue · 5 comments
this surface today when trying to do something like this:
root.I13N_config.section.2sv = {"id":"module-2sv","pp":{}};
In theory, we should be able to construct the proper namespace.
I don't understand the problem. Could you elaborate? The example code in the issue seems fine to me.
Identifiers can't start with a number (2sv
in caridy's example).
Ah yes, so not a valid namespace. It was an explicit decision to only support namespacing, i.e. dot-notation in Express State. Reason being that usually it's an abuse of the library if need something more complex.
@caridy in this example can you explain why you can't do:
res.expose(i13n.config, 'I13N_config');
…instead of exposing two levels of sub-props?
in this particular case, it is because sections
is built by each individual parts of the page, adding page sections to that namespace, and it is actually sugared by something like this:
res.trackSection('sec-value', 'DOM-id', {});
which translate into the corresponding expose()
call.
I still don't think we should change how this package works to accommodate this change in definition of what a namespace is to Express State. A namespace should always be able to be accessed via dot notation — this change would conflate a namespace with data.