Skip to content
This repository has been archived by the owner on May 19, 2018. It is now read-only.

Estree: Fix stmt value being the raw value #557

Merged
merged 1 commit into from
Jun 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/plugins/estree.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,17 @@ export default (superClass: Class<Parser>): Class<Parser> => 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);

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"
}
]
}
}
}