diff --git a/lib/convert.js b/lib/convert.js
index 564cd01..1d55359 100644
--- a/lib/convert.js
+++ b/lib/convert.js
@@ -290,9 +290,7 @@ module.exports = function convert(config) {
// Assign the appropriate types
tagNameToken.object.type = (isNestedMemberExpression) ? AST_NODE_TYPES.JSXMemberExpression : AST_NODE_TYPES.JSXIdentifier;
tagNameToken.property.type = AST_NODE_TYPES.JSXIdentifier;
-
} else {
-
tagNameToken.name = tagNameToken.value;
}
@@ -1447,6 +1445,9 @@ module.exports = function convert(config) {
property: convertChild(node.name)
};
const isNestedMemberExpression = (node.expression.kind === SyntaxKind.PropertyAccessExpression);
+ if (node.expression.kind === SyntaxKind.ThisKeyword) {
+ jsxMemberExpression.object.name = "this";
+ }
jsxMemberExpression.object.type = (isNestedMemberExpression) ? AST_NODE_TYPES.MemberExpression : AST_NODE_TYPES.JSXIdentifier;
jsxMemberExpression.property.type = AST_NODE_TYPES.JSXIdentifier;
diff --git a/tests/fixtures/jsx/member-expression-this.result.js b/tests/fixtures/jsx/member-expression-this.result.js
new file mode 100644
index 0000000..2df3406
--- /dev/null
+++ b/tests/fixtures/jsx/member-expression-this.result.js
@@ -0,0 +1,327 @@
+module.exports = {
+ "type": "Program",
+ "range": [
+ 0,
+ 25
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 0
+ },
+ "end": {
+ "line": 1,
+ "column": 25
+ }
+ },
+ "body": [
+ {
+ "type": "ExpressionStatement",
+ "range": [
+ 0,
+ 25
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 0
+ },
+ "end": {
+ "line": 1,
+ "column": 25
+ }
+ },
+ "expression": {
+ "type": "JSXElement",
+ "range": [
+ 0,
+ 24
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 0
+ },
+ "end": {
+ "line": 1,
+ "column": 24
+ }
+ },
+ "openingElement": {
+ "type": "JSXOpeningElement",
+ "range": [
+ 0,
+ 24
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 0
+ },
+ "end": {
+ "line": 1,
+ "column": 24
+ }
+ },
+ "selfClosing": true,
+ "name": {
+ "type": "JSXMemberExpression",
+ "range": [
+ 1,
+ 21
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 1
+ },
+ "end": {
+ "line": 1,
+ "column": 21
+ }
+ },
+ "object": {
+ "type": "JSXMemberExpression",
+ "range": [
+ 1,
+ 11
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 1
+ },
+ "end": {
+ "line": 1,
+ "column": 11
+ }
+ },
+ "object": {
+ "type": "JSXIdentifier",
+ "range": [
+ 1,
+ 5
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 1
+ },
+ "end": {
+ "line": 1,
+ "column": 5
+ }
+ },
+ "name": "this"
+ },
+ "property": {
+ "type": "JSXIdentifier",
+ "range": [
+ 6,
+ 11
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 6
+ },
+ "end": {
+ "line": 1,
+ "column": 11
+ }
+ },
+ "name": "state"
+ }
+ },
+ "property": {
+ "type": "JSXIdentifier",
+ "range": [
+ 12,
+ 21
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 12
+ },
+ "end": {
+ "line": 1,
+ "column": 21
+ }
+ },
+ "name": "Component"
+ }
+ },
+ "attributes": []
+ },
+ "closingElement": null,
+ "children": []
+ }
+ }
+ ],
+ "sourceType": "script",
+ "tokens": [
+ {
+ "type": "Punctuator",
+ "value": "<",
+ "range": [
+ 0,
+ 1
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 0
+ },
+ "end": {
+ "line": 1,
+ "column": 1
+ }
+ }
+ },
+ {
+ "type": "Keyword",
+ "value": "this",
+ "range": [
+ 1,
+ 5
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 1
+ },
+ "end": {
+ "line": 1,
+ "column": 5
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": ".",
+ "range": [
+ 5,
+ 6
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 5
+ },
+ "end": {
+ "line": 1,
+ "column": 6
+ }
+ }
+ },
+ {
+ "type": "JSXIdentifier",
+ "value": "state",
+ "range": [
+ 6,
+ 11
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 6
+ },
+ "end": {
+ "line": 1,
+ "column": 11
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": ".",
+ "range": [
+ 11,
+ 12
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 11
+ },
+ "end": {
+ "line": 1,
+ "column": 12
+ }
+ }
+ },
+ {
+ "type": "JSXIdentifier",
+ "value": "Component",
+ "range": [
+ 12,
+ 21
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 12
+ },
+ "end": {
+ "line": 1,
+ "column": 21
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "/",
+ "range": [
+ 22,
+ 23
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 22
+ },
+ "end": {
+ "line": 1,
+ "column": 23
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": ">",
+ "range": [
+ 23,
+ 24
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 23
+ },
+ "end": {
+ "line": 1,
+ "column": 24
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": ";",
+ "range": [
+ 24,
+ 25
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 24
+ },
+ "end": {
+ "line": 1,
+ "column": 25
+ }
+ }
+ }
+ ]
+};
diff --git a/tests/fixtures/jsx/member-expression-this.src.js b/tests/fixtures/jsx/member-expression-this.src.js
new file mode 100644
index 0000000..f3bd61b
--- /dev/null
+++ b/tests/fixtures/jsx/member-expression-this.src.js
@@ -0,0 +1 @@
+;
diff --git a/tests/fixtures/jsx/member-expression.result.js b/tests/fixtures/jsx/member-expression.result.js
new file mode 100644
index 0000000..a69bd26
--- /dev/null
+++ b/tests/fixtures/jsx/member-expression.result.js
@@ -0,0 +1,397 @@
+module.exports = {
+ "type": "Program",
+ "range": [
+ 0,
+ 11
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 0
+ },
+ "end": {
+ "line": 1,
+ "column": 11
+ }
+ },
+ "body": [
+ {
+ "type": "ExpressionStatement",
+ "range": [
+ 0,
+ 11
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 0
+ },
+ "end": {
+ "line": 1,
+ "column": 11
+ }
+ },
+ "expression": {
+ "type": "JSXElement",
+ "range": [
+ 0,
+ 11
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 0
+ },
+ "end": {
+ "line": 1,
+ "column": 11
+ }
+ },
+ "openingElement": {
+ "type": "JSXOpeningElement",
+ "range": [
+ 0,
+ 5
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 0
+ },
+ "end": {
+ "line": 1,
+ "column": 5
+ }
+ },
+ "selfClosing": false,
+ "name": {
+ "type": "JSXMemberExpression",
+ "range": [
+ 1,
+ 4
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 1
+ },
+ "end": {
+ "line": 1,
+ "column": 4
+ }
+ },
+ "object": {
+ "type": "JSXIdentifier",
+ "range": [
+ 1,
+ 2
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 1
+ },
+ "end": {
+ "line": 1,
+ "column": 2
+ }
+ },
+ "name": "a"
+ },
+ "property": {
+ "type": "JSXIdentifier",
+ "range": [
+ 3,
+ 4
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 3
+ },
+ "end": {
+ "line": 1,
+ "column": 4
+ }
+ },
+ "name": "b"
+ }
+ },
+ "attributes": []
+ },
+ "closingElement": {
+ "type": "JSXClosingElement",
+ "range": [
+ 5,
+ 11
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 5
+ },
+ "end": {
+ "line": 1,
+ "column": 11
+ }
+ },
+ "name": {
+ "type": "JSXMemberExpression",
+ "range": [
+ 7,
+ 10
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 7
+ },
+ "end": {
+ "line": 1,
+ "column": 10
+ }
+ },
+ "object": {
+ "type": "JSXIdentifier",
+ "range": [
+ 7,
+ 8
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 7
+ },
+ "end": {
+ "line": 1,
+ "column": 8
+ }
+ },
+ "name": "a"
+ },
+ "property": {
+ "type": "JSXIdentifier",
+ "range": [
+ 9,
+ 10
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 9
+ },
+ "end": {
+ "line": 1,
+ "column": 10
+ }
+ },
+ "name": "b"
+ }
+ }
+ },
+ "children": []
+ }
+ }
+ ],
+ "sourceType": "script",
+ "tokens": [
+ {
+ "type": "Punctuator",
+ "value": "<",
+ "range": [
+ 0,
+ 1
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 0
+ },
+ "end": {
+ "line": 1,
+ "column": 1
+ }
+ }
+ },
+ {
+ "type": "JSXIdentifier",
+ "value": "a",
+ "range": [
+ 1,
+ 2
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 1
+ },
+ "end": {
+ "line": 1,
+ "column": 2
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": ".",
+ "range": [
+ 2,
+ 3
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 2
+ },
+ "end": {
+ "line": 1,
+ "column": 3
+ }
+ }
+ },
+ {
+ "type": "JSXIdentifier",
+ "value": "b",
+ "range": [
+ 3,
+ 4
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 3
+ },
+ "end": {
+ "line": 1,
+ "column": 4
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": ">",
+ "range": [
+ 4,
+ 5
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 4
+ },
+ "end": {
+ "line": 1,
+ "column": 5
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "<",
+ "range": [
+ 5,
+ 6
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 5
+ },
+ "end": {
+ "line": 1,
+ "column": 6
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "/",
+ "range": [
+ 6,
+ 7
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 6
+ },
+ "end": {
+ "line": 1,
+ "column": 7
+ }
+ }
+ },
+ {
+ "type": "JSXIdentifier",
+ "value": "a",
+ "range": [
+ 7,
+ 8
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 7
+ },
+ "end": {
+ "line": 1,
+ "column": 8
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": ".",
+ "range": [
+ 8,
+ 9
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 8
+ },
+ "end": {
+ "line": 1,
+ "column": 9
+ }
+ }
+ },
+ {
+ "type": "JSXIdentifier",
+ "value": "b",
+ "range": [
+ 9,
+ 10
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 9
+ },
+ "end": {
+ "line": 1,
+ "column": 10
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": ">",
+ "range": [
+ 10,
+ 11
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 10
+ },
+ "end": {
+ "line": 1,
+ "column": 11
+ }
+ }
+ }
+ ]
+};
diff --git a/tests/fixtures/jsx/member-expression.src.js b/tests/fixtures/jsx/member-expression.src.js
new file mode 100644
index 0000000..a5cd092
--- /dev/null
+++ b/tests/fixtures/jsx/member-expression.src.js
@@ -0,0 +1 @@
+