From eeba7148da03eb92d65a3e610ac761420e13c055 Mon Sep 17 00:00:00 2001 From: Daniel Tschinder Date: Sat, 3 Jun 2017 16:21:53 +0200 Subject: [PATCH] Fix stmt value being the raw value (#557) (#558) --- src/plugins/estree.js | 13 +++++++++++++ test/fixtures/estree/directives/raw/expected.json | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/plugins/estree.js b/src/plugins/estree.js index 3502e311bf..f2275e83e2 100644 --- a/src/plugins/estree.js +++ b/src/plugins/estree.js @@ -128,6 +128,19 @@ export default function (instance) { }; }); + instance.extend("stmtToDirective", function (inner) { + return function (stmt) { + const directive = inner.call(this, 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; + }; + }); + instance.extend("parseBlockBody", function (inner) { return function (node, ...args) { inner.call(this, 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 +}