estree: correctly change literals in all cases (#368)

This commit is contained in:
Daniel Tschinder
2017-02-20 23:47:57 +01:00
committed by GitHub
parent 2ef00a6631
commit b023470c7e
3 changed files with 128 additions and 5 deletions

View File

@@ -18,11 +18,7 @@ pp.estreeParseRegExpLiteral = function ({ pattern, flags }) {
};
pp.estreeParseLiteral = function (value) {
const node = this.parseLiteral(value, "Literal");
node.raw = node.extra.raw;
delete node.extra;
return node;
return this.parseLiteral(value, "Literal");
};
pp.directiveToStmt = function (directive) {
@@ -177,6 +173,16 @@ export default function (instance) {
};
});
instance.extend("parseLiteral", function(inner) {
return function (...args) {
const node = inner.call(this, ...args);
node.raw = node.extra.raw;
delete node.extra;
return node;
};
});
instance.extend("parseMethod", function(inner) {
return function (node, ...args) {
let funcNode = this.startNode();