Fixed 'use strict' check.
This commit is contained in:
parent
b6e8dd49e4
commit
0aca3b9667
1 changed files with 4 additions and 3 deletions
|
@ -411,9 +411,10 @@ module ts {
|
|||
}
|
||||
|
||||
/// Should be called only on prologue directives (isPrologueDirective(node) should be true)
|
||||
function isUseStrictPrologueDirective(node: Node): boolean {
|
||||
function isUseStrictPrologueDirective(sourceFile: SourceFile, node: Node): boolean {
|
||||
Debug.assert(isPrologueDirective(node));
|
||||
return getTextOfNode((<ExpressionStatement>node).expression) === '"use strict"';
|
||||
var nodeText = getSourceTextOfNodeFromSourceFile(sourceFile,(<ExpressionStatement>node).expression);
|
||||
return nodeText === '"use strict"' || nodeText === "'use strict'";
|
||||
}
|
||||
|
||||
export function createSourceFile(filename: string, sourceText: string, languageVersion: ScriptTarget, version: string, isOpen: boolean = false): SourceFile {
|
||||
|
@ -1073,7 +1074,7 @@ module ts {
|
|||
// test elements only if we are not already in strict mode
|
||||
if (checkForStrictMode && !inStrictModeContext()) {
|
||||
if (isPrologueDirective(element)) {
|
||||
if (isUseStrictPrologueDirective(element)) {
|
||||
if (isUseStrictPrologueDirective(sourceFile, element)) {
|
||||
setStrictModeContext(true);
|
||||
checkForStrictMode = false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue