-
Notifications
You must be signed in to change notification settings - Fork 58
Add support for XML/XJS identifier namespaces #7
Conversation
Updated as per our discussions, just shout if there's anything you want changed/improved. |
@@ -1801,6 +1803,18 @@ parseYieldExpression: true | |||
}; | |||
}, | |||
|
|||
createXJSMemberExpression: function (object, property) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see why we need a special creator function...why not just use delegate.createMemberExpression()
inside parseXJSMemberExpression
? That way we don't have to invent a new node that is really just a copy of an existing node type...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per convo in IRC, you're right that this makes the most sense...since it's property
attribute will be of type XJSIdentifier
(whereas regular MemberExpression
nodes would have vanilla a Identifier
)
Oh, and can you please add some tests to tests to |
@jeffmo Can add tests for sure, Also, I had overlooked checking the first Or perhaps better yet just do it properly, strip |
Tests pushed. |
I think wrapping identifiers in some kind of namespace node is the right thing to do longer term. If it didn't also mean that we'll have to make corresponding changes to the transform, I wouldn't be opposed to you taking a stab at it in this diff -- so let's just do that in a separate follow-up diff to simplify cross-compat between this change and the transform changes that'll need to happen. As for adding a bool parameter to parseXJSIdentifier -- let's just do the assert explicitly where the logic calls for it (even if that means doing it in two places). Boolean params are bad news for readers of code: They're context-less at call sites, so readers have to go look up the function definition to understand what they mean. |
column: 4, | ||
message: "Error: Line 1: Unexpected token >" | ||
}, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also add an error-test for <a[foo]></a[foo]>
and <a['foo']></a['foo']>
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For sure, pushed!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although <a[foo]></a[foo]>
should have been enough seeing as you can't get to ['foo']
without the other syntax being supported (or at least producing a different error message).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, I kind of just wanted to use the test as a way of documenting that we are explicitly not supporting this case
@jeffmo Sounds reasonable. Thought; could rename |
FYI, the JSXTransformer PR can be landed before this esprima PR without any interference. |
Lets wait on splitting out the namespacing (and by wait, I just mean put it in a separate follow-up PR stacked on top of this one -- you can put it out now if you're ready) Let me pull this in and run our internal tests, then I think we're good to go if that's all set. cc @benjamn as I think this might also need a corresponding update to your ast-types repo? |
Ok one final thing: Can you run |
Coverage complains: I looked through the coverage report and all I found was a not-meant-to-be-reached assert of mine, which I can't cover in a test (obviously). Do you want me to increase the statements threshold (where?) or what do you prefer? |
Add support for XML/XJS identifier namespaces
Depends on approval of facebook/react#760