Skip to content
This repository was archived by the owner on Apr 10, 2023. It is now read-only.

Commit 2627aaa

Browse files
committed
fix(MemberExpression): 🐛Fix MemberExpression with UnaryExpression
1 parent 3623123 commit 2627aaa

File tree

5 files changed

+44
-0
lines changed

5 files changed

+44
-0
lines changed

lib/__tests__/fixtures/parse/logical-expression-000/input.js renamed to lib/__tests__/fixtures/parse/member-expression-003/input.js

File renamed without changes.

lib/__tests__/fixtures/parse/logical-expression-000/output.json renamed to lib/__tests__/fixtures/parse/member-expression-003/output.json

File renamed without changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
!item || !item.src
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"type": "Program",
3+
"body": [
4+
{
5+
"type": "ExpressionStatement",
6+
"expression": {
7+
"type": "LogicalExpression",
8+
"operator": "||",
9+
"left": {
10+
"type": "UnaryExpression",
11+
"operator": "!",
12+
"argument": {
13+
"type": "Identifier",
14+
"name": "item"
15+
}
16+
},
17+
"right": {
18+
"type": "UnaryExpression",
19+
"operator": "!",
20+
"argument": {
21+
"type": "MemberExpression",
22+
"object": {
23+
"type": "Identifier",
24+
"name": "item"
25+
},
26+
"property": {
27+
"type": "Identifier",
28+
"name": "src"
29+
},
30+
"computed": false
31+
}
32+
}
33+
}
34+
}
35+
]
36+
}

lib/parse.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,13 @@ module.exports = function parse(input) {
469469
computed
470470
);
471471
break;
472+
case astTypes.UNARY_EXPRESSION:
473+
parent.argument = new astFactory.MemberExpression(
474+
parent.argument,
475+
expression,
476+
computed
477+
);
478+
break;
472479
default:
473480
throwError('Unexpected parent.type: ' + parent.type);
474481
}

0 commit comments

Comments
 (0)