@samitouri / QOS-React-2 / commits / 2c85658c69

[jsx] Make sure we throw when we get XML namespaces

https://github.com/facebook/esprima/commit/aad8a2b798ca80342a744aac2869fc1feb0065dd replaced XJSIdentifer with XJSNamespacedName for namespaced items, so we need to adjust here accordingly.

Paul O’Shannessy committed Jun 18, 2014 at 17:16 UTC 2c85658c69c8037540e06c9655bb7ecee0836e0c
1 file changed +7 -9
vendor/fbtransform/transforms/react.js
+7 -9
@@ -57,17 +57,15 @@ function visitReactTag(traverse, object, path, state) {
57
58 utils.catchup(openingElement.range[0], state, trimLeft);
59
60 - var isFallbackTag = false;
61 -
62 - if (nameObject.type === Syntax.XJSIdentifier) {
63 - if (nameObject.namespace) {
64 - throw new Error(
65 - 'Namespace tags are not supported. ReactJSX is not XML.');
66 - }
67 -
68 - isFallbackTag = FALLBACK_TAGS.hasOwnProperty(nameObject.name);
60 + if (nameObject.type === Syntax.XJSNamespacedName && nameObject.namespace) {
61 + throw new Error('Namespace tags are not supported. ReactJSX is not XML.');
62 }
63
64 + // Only identifiers can be fallback tags. XJSMemberExpressions are not.
65 + var isFallbackTag =
66 + nameObject.type === Syntax.XJSIdentifier &&
67 + FALLBACK_TAGS.hasOwnProperty(nameObject.name);
68 +
69 utils.append(isFallbackTag ? jsxObjIdent + '.' : '', state);
70
71 utils.move(nameObject.range[0], state);