Skip to content

Commit 582a413

Browse files
Cellulemichaelficarra
authored andcommitted
MetaProperty fields as Identifier (estools#369)
Keep support for plain strings for backward compatibility
1 parent f0488e1 commit 582a413

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

escodegen.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1943,9 +1943,9 @@
19431943
MetaProperty: function (expr, precedence, flags) {
19441944
var result;
19451945
result = [];
1946-
result.push(expr.meta);
1946+
result.push(typeof expr.meta === "string" ? expr.meta : generateIdentifier(expr.meta));
19471947
result.push('.');
1948-
result.push(expr.property);
1948+
result.push(typeof expr.property === "string" ? expr.property : generateIdentifier(expr.property));
19491949
return parenthesize(result, Precedence.Member, precedence);
19501950
},
19511951

test/harmony-esprima2.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ var esprima = require('./3rdparty/esprima-2.7.1'),
3939

4040
data = {
4141
'Harmony MetaProperty': {
42-
'class SomeClass { constructor() { if (new.target === SomeClass) { throw new Error(\'Boom\'); }}}': {
42+
'class SomeClass { constructor() { if (new.target === SomeClass) { throw new Error(\'Boom\'); }}}': {
4343
type: 'Program',
4444
body: [ {
4545
type: "ClassDeclaration",
@@ -73,8 +73,14 @@ data = {
7373
operator: "===",
7474
left: {
7575
type: "MetaProperty",
76-
meta: "new",
77-
property: "target"
76+
meta: {
77+
type: "Identifier",
78+
name: "new"
79+
},
80+
property: {
81+
type: "Identifier",
82+
name: "target"
83+
},
7884
},
7985
right: {
8086
type: "Identifier",

0 commit comments

Comments
 (0)