Preserve namespaced attributes when throwIfNamespace is false (#7173)

Previously that part would throw since it expects a JSXIdentifier but it (logically) gets a JSXNamespacedName when using a namespaced attribute.
This commit is contained in:
mtpc 2018-01-09 06:24:02 +01:00 committed by Logan Smyth
parent 74682f33bc
commit 63157159ab
3 changed files with 9 additions and 3 deletions

View File

@ -92,7 +92,11 @@ You can turn on the 'throwIfNamespace' flag to bypass this warning.`,
if (t.isValidIdentifier(node.name.name)) {
node.name.type = "Identifier";
} else {
node.name = t.stringLiteral(node.name.name);
node.name = t.stringLiteral(
t.isJSXNamespacedName(node.name)
? node.name.namespace.name + ":" + node.name.name.name
: node.name.name,
);
}
return t.inherits(t.objectProperty(node.name, value), node);

View File

@ -1 +1,3 @@
h("f:image", null);
h("f:image", {
"n:attr": true
});