Syntax highlighting is crazy for some JSX construct
Here is the code that makes the syntax highlighting crazy:
render() {
this._scheduleDraw();
return (
<div className={this.props.className}>
<canvas
className={classNames(
`${this.props.className}Canvas`,
'threadStackGraphCanvas'
)}
ref={ref => (this._canvas = ref)}
onMouseUp={this._onMouseUp}
/>
</div>
);
}
See how it renders:

It would be nice to see what is available w/ codemirror, maybe others have found a good solution?
Maybe CodeMirror's latest version has fixed it? I don't see a note in the changelog about the JSX mode specifically. Also maybe worth reporting to them if it does seem broken.
It was easy to actually try:

Yep, it looks like Code Mirror's newer versions actually fix this.
Though some of the colors are still weird: see the angle bracket in the ref's arrow function, or onMouseUp not having the right color, or the closing div tag.
But it's not as broken as it was.
I added this example in that issue: https://github.com/codemirror/CodeMirror/issues/3745#issuecomment-340389826
Ah, they answered that we should be in JSX mode, and this actually works in JSX mode (while JS mode still shows the same issue as initially shown). I don't know if there's any drawbacks using this mode for all JS code, I asked there.
Thanks @julienw we can be pretty smart about the mode if we parse the source text and see a JSX node
when was the JSX mode introduced? should we try to do this w/ 28? or jump and do it?
@jasonLaster jsx mode was introduced in v5.11.0. in Jan 2016
@julienw Are you already onto it? Otherwise I'd claim it and look if we always can always use jsx mode for javascript
@nyrosmith I'm not, I was just trying to make things clear :)
They say there shouldn't be any drawback to always use JSX, but maybe there are other implications, like performance.
@julienw can you provide an URL I can test the changes?
/claim
Thanks for claiming the issue! :wave:
Here are some links for getting setup, contributing, and developing. We're always happy to answer questions in slack! If you become busy, feel free to /unclaim it.
:fox_face: Debugger team!
I don't have one easily usable online.
But here is a not-so-simple STR:
- clone https://github.com/devtools-html/perf.html/
- run
yarn install && yarn start - with Firefox, go to http://localhost:4242/public/1ecd7a421948995171a4bb483b7bcc8e1868cc57/calltree/
- Open the Debugger and open the file webpack > src > components > shared > TreeView.js
You'll see most of the file is blue because of the pattern className={`treeViewHeaderColumn treeViewFixedColumn ${col.propName}`} line 34.
That's fine for me. Let's see if I can improve the highlighting