Skip to content

[JSX] Add scope to native tags. #3000

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

Merged
merged 2 commits into from
Aug 27, 2021

Conversation

Thom1729
Copy link
Collaborator

Requested by DouglasVarollo on Discord.

The uppercase/lowercase distinction isn't exactly syntactic, but it's not spurious either. When Babel translates JSX element to a React.createElement() call, lowercase tag names without any punctuation are translated to strings, whereas all other tags names are translated to expressions that reference variables in scope, e.g:

<foo />; // → React.createElement("foo", null);
<Foo />; // → React.createElement(Foo, null);
<foo.bar />; // → React.createElement(foo.bar, null);

This implementation will fail in cases with line breaks like <foo\n.bar />, but since this is basically cosmetic, I don't think this is a big deal.

I picked the scope entity.name.tag.native, mostly at random.

@Thom1729 Thom1729 merged commit 685e4b1 into sublimehq:master Aug 27, 2021
@Thom1729 Thom1729 deleted the jsx-native-tag-names branch August 27, 2021 18:34
mitranim pushed a commit to mitranim/Packages that referenced this pull request Mar 25, 2022
* [JSX] Add scope to native tags.

* Update JavaScript/JSX.sublime-syntax

Co-authored-by: deathaxe <[email protected]>

Co-authored-by: deathaxe <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants