镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

JSX version 1.1 - non-breaking changes #117

Description

@kunukn

Some features has been proposed before, but nothing seems to be happening even though they get upvoted.

Would it be easier if we think in terms of non-breaking changes to update the JSX specification?

E.g. I believe this is a non-breaking addition to the JSX specification.

<Foo bar=2 />
#64

In JSX 1.1 you would then have the options

<Foo bar=2 />
<Foo bar={2} />

JSX 1.0 (current version) you have the option

<Foo bar={2} />


Option 1: <Foo bar=2 /> this could be evaluated to an AssignmentExpression without the { }

The generated AST should be identical for

<Foo bar=2 /> and <Foo bar={2} />


Option 2: We could extend allowed values for JSXAttributeValue
https://facebook.github.io/jsx/

JSXAttributeValue :

  • JSXNumber
  • JSXDoubleStringCharacters "
  • JSXSingleStringCharacters '
  • AssignmentExpression {}
  • JSXElement <
  • JSXFragment <

The definition of JSXNumber could be typeof number

e.g.

2, 0x10, NaN


Could this be generalised?
Allow non-breaking changes where we omit the brackets for JSXAttributeValue?

e.g.

<Button 
  onClick = { onCreate } 
  id = { 123 } 
  zIndex = { 1 } 
  onMouseOver = { onMouseOverCreateButton }>
    Create
</Button>

Could also be

<Button 
  onClick = onCreate  
  id = 123  
  zIndex = 1 
  onMouseOver = onMouseOverCreateButton>
    Create
</Button>

Languages evolves and gets updated.

I see JSX as an essential part of React that makes it popular and loved.
I hope the JSX specification evolves over time. Even if is small minor syntax sugar improvements.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ProposalProposals (haven't confirmed)Proposal LivingProposals considerable for the living JSX

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions