From 47af470e6e0578cf130bbf781c8b2ee0bffa19c0 Mon Sep 17 00:00:00 2001 From: Daniel Tschinder Date: Sat, 3 Jun 2017 12:40:13 +0200 Subject: [PATCH] Fix stmt value being the raw value --- src/plugins/estree.js | 11 +++++++++++ test/fixtures/estree/directives/raw/expected.json | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/plugins/estree.js b/src/plugins/estree.js index 637f8e23d8..c492f9f57c 100644 --- a/src/plugins/estree.js +++ b/src/plugins/estree.js @@ -125,6 +125,17 @@ export default (superClass: Class): Class => class extends super (!stmt.expression.extra || !stmt.expression.extra.parenthesized); } + stmtToDirective(stmt: N.Statement): N.Directive { + const directive = super.stmtToDirective(stmt); + const value = stmt.expression.value; + + // Reset value to the actual value as in estree mode we want + // the stmt to have the real value and not the raw value + directive.value.value = value; + + return directive; + } + parseBlockBody(node: N.BlockStatementLike, ...args): void { super.parseBlockBody(node, ...args); diff --git a/test/fixtures/estree/directives/raw/expected.json b/test/fixtures/estree/directives/raw/expected.json index 7467c2bffc..b1d0f267c4 100644 --- a/test/fixtures/estree/directives/raw/expected.json +++ b/test/fixtures/estree/directives/raw/expected.json @@ -56,11 +56,11 @@ "column": 15 } }, - "value": "use\\x20strict", + "value": "use strict", "raw": "\"use\\x20strict\"" }, "directive": "use\\x20strict" } ] } -} \ No newline at end of file +}