Skip to content
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

JSX: Bug highlighting object spread with object property access #1236

Closed
jlmakes opened this issue Nov 29, 2017 · 3 comments
Closed

JSX: Bug highlighting object spread with object property access #1236

jlmakes opened this issue Nov 29, 2017 · 3 comments

Comments

@jlmakes
Copy link

jlmakes commented Nov 29, 2017

Reproducing The Issue

Spread over a nested object as component props, such as {...this.props} below:

const Component = () =>
    <Child {...this.props} option={400}>
        <div>foo</div>
        <div>bar</div>
        <div>jam</div>
    </Child>

. . .

Test Drive Results

screen shot 2017-11-29 at 6 18 28 am

The highlighting for the line <Child {...this.props} option={400}> is a bit off.

. . .

If we don't use the object property access operator, and replace this.props with somePropsObj for example, we can see how the highlighting kicks back in:

screen shot 2017-11-29 at 6 15 19 am

. . .

Related: #1235

@jlmakes
Copy link
Author

jlmakes commented Nov 29, 2017

I spy {\.{3}\w+\} in /components/prism-jsx.js on line 6

@Golmote
Copy link
Contributor

Golmote commented Nov 29, 2017

Thanks for reporting. It should be fixed now.

Note, though, that Prism will still fail on other cases. AFAIK JSX can contain almost all JS has to offer in those tags, and matching everything would be really complicated with just regexps.

Examples that will fail, and I think we won't fix, include:

// Spread with anything other than a variable or a simple property access
<Child {...{foo: 'bar', bar: 'baz'}}>
// Nested objects in attribute value
<Child foo={{ foo: { bar: 'baz'}}}>

I'm not even sure those are valid JSX example, but I do know they would fail.

@jlmakes
Copy link
Author

jlmakes commented Dec 1, 2017

Really appreciate the fix @Golmote, hyper merci

@Golmote Golmote closed this as completed Dec 5, 2017
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

No branches or pull requests

2 participants