Skip to content

Commit

Permalink
Fix stmt value being the raw value (babel#557) (babel#558)
Browse files Browse the repository at this point in the history
  • Loading branch information
danez committed Jun 3, 2017
1 parent e212701 commit eeba714
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
13 changes: 13 additions & 0 deletions src/plugins/estree.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/estree/directives/raw/expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@
"column": 15
}
},
"value": "use\\x20strict",
"value": "use strict",
"raw": "\"use\\x20strict\""
},
"directive": "use\\x20strict"
}
]
}
}
}

0 comments on commit eeba714

Please sign in to comment.