rjsx-mode icon indicating copy to clipboard operation
rjsx-mode copied to clipboard

Allow props to take a JSX literal value

Open felipeochoa opened this issue 7 years ago • 4 comments

Also per the spec on the repo, apparently props can be assigned literal JSX elements directly

JSXAttributeInitializer :


  • = JSXAttributeValue

JSXAttributeValue :


  • " JSXDoubleStringCharactersopt "
  • ' JSXSingleStringCharactersopt '
  • { AssignmentExpression }
  • JSXElement

felipeochoa avatar Nov 07 '16 08:11 felipeochoa

This isn't hard at all, the hardest part is to not mess up indentation even more than it is now. js-mode's indent-line-function is just superbly stupid even in Emacs 26.

It'll probably make more sense to reimplement indent-line-function first.

wyuenho avatar May 13 '18 02:05 wyuenho

Oh well, no need to hurry tho, not until Babel 7 is released anyway, whenever that maybe.

wyuenho avatar May 17 '18 02:05 wyuenho

It's released! https://babeljs.io/blog/2018/08/27/7.0.0

wyuenho avatar Aug 28 '18 00:08 wyuenho

PRs welcome :) I think it's an easy fix on the parsing side, we just need some tests here. On the indentation side, I'd have to check, but I think there's an assumption that if a node and its parent are both rjsx-nodes, then it's a nested relationship rather than a tag-attribute relationship. If only I'd added an rjsx-tag node to the parse tree...

felipeochoa avatar Aug 28 '18 03:08 felipeochoa