-
Notifications
You must be signed in to change notification settings - Fork 48.5k
Tag name for jsxtransformer cannot be "namespaced" #221
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
Comments
We talked about it several times and we agreed that we should support <Namespace.Component> but no one actually wrote the code to support it yet. In the meantime you can do Thanks for the report :) |
(See #74.) |
I start holidays next week, so I'll try to take a stab at it if it still won't be resolved. |
@vjeux @zpao what do you think about https://github.com/jakubmal/esprima/tree/namespaced-jsx-tags I based it on commit a3e0ea3979eb8d54d8bfade220c272903f928b1e in facebook/esprima, because there is a lot of new commits in a3e0eea...master, so we either need to make a branch in facebook/esprima, or update version of esprima used in react. @vjeux as you said on irc, the fix is really a one-liner, maybe guys from facebook/esprima will want to have more tests on this, but apart from that, really easy. |
@jeffmo, this is all you on the esprima side. We'll obviously want to make sure this change is fine internally before we take it. @JakubMal Feel free to open PRs against facebook/esprima#fb-harmony (that's the branch we use internally and here in React - npm has git dependency issues, that's why we point at a tarball for a rev in our package.json). I think we intentionally lag behind master since we've done some considerable work in our branch, though @jeffmo knows better. We'll almost certainly want some tests :) We didn't add our other tests in |
I think this is mostly fine, but I would like for us to continue using xml semantics if we want to go down this road. So instead of |
@JakubMal: I said that it shouldn't be too hard. But I'm pretty sure it's not a one liner :) |
Going with i.e. Does it compile to If we go with |
Is it too late to voice an opinion? I'm not so sure if implementing namespace is a good idea, for three reasons:
|
Well,
I suggested something extremely simple like:
to translate to App.Views.Counter({}) And I suggested to simply include dot (.) as allowed char in tag name, then the whole tag name including dots is copy&pasted into resulting JS. I believe it doesn't have any wider implications if you commit to reserving dot for this case, and you're still left with a colon. It might help in say 2-3% of all the situations, so if it is such a hassle, then let's just leave it. |
With regard to including dot as an allowed character in the tag name: This not the right approach for the parser. If the intent of On the |
(I should note that I also don't feel terribly strongly about the need for this feature -- but if done in a future-friendly way, I'm willing to take the pull request) |
I am not really sure, could you clarify? How is it that dot is locking us into "nested objects"? If "nested objects" as tag names are implemented using colon then it locks colon into this meaning in the same way it would lock dot into this meaning. It is analogical, isn't it. Please, let me understand it here. Given #74 and implementing nested objects as member expression do you still think it is not the right solution? If not, then closing. |
To be clear I wasn't suggesting that we parse colon delimiters into member expressions, but just that we parse them into some kind of "namespace" structure in the syntax tree so they can be interpreted more freely by the compiler. If we used Whereas |
In that case (parametrizable namespaces), right now I don't have the amount of time it would take to implement it (conditional member expression parsing, tests, cli switch, react-rails config&tests off the top of my head) |
Using a colon as a separator conventionally locks you into a single level of namespacing - Perhaps allowing the tag name to be supplied as an expression would provide the flexibility desired? This would allow even complex tag expressions to be expressed clearly, e.g. |
@lrowe: Its possible to represent an arbitrarily deep number of nested namespaces as such:
This turns out to be true regardless of what the namespacing delimiter is -- my only issue with |
@lrowe You can already do what you want using a temporary variable as follows:
This also enables you to add children to it:
Otherwise there's an issue where it's unclear what you put in the end tag:
|
Use a heuristic for locating roots
But when Component is a field of an other object:
it fails with
(nvm here is a node version manager, just like rvm but for node, you can find it on github)
I hope it's not as RTFM case :)
Even if it's not supported currently, it would be a nice feature IMHO. I'm not that familiar with the code to come up with a PR unfortunately.
The text was updated successfully, but these errors were encountered: