diff --git a/lib/6to5/transformation/transformers/other/use-strict.js b/lib/6to5/transformation/transformers/other/use-strict.js index 3965a463de..2d3c6750bd 100644 --- a/lib/6to5/transformation/transformers/other/use-strict.js +++ b/lib/6to5/transformation/transformers/other/use-strict.js @@ -17,5 +17,5 @@ exports.FunctionExpression = function (node, parent, scope, context) { }; exports.ThisExpression = function (node, parent, scope, context, file) { - throw file.errorWithNode(node, "Top level `this` is `undefined` in strict mode", ReferenceError); + return t.identifier("undefined"); }; diff --git a/test/fixtures/transformation/use-strict/illegal-this-root-call/options.json b/test/fixtures/transformation/use-strict/illegal-this-root-call/options.json deleted file mode 100644 index 3137168db6..0000000000 --- a/test/fixtures/transformation/use-strict/illegal-this-root-call/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Top level `this` is `undefined` in strict mode" -} diff --git a/test/fixtures/transformation/use-strict/illegal-this-root-declaration/options.json b/test/fixtures/transformation/use-strict/illegal-this-root-declaration/options.json deleted file mode 100644 index 3137168db6..0000000000 --- a/test/fixtures/transformation/use-strict/illegal-this-root-declaration/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Top level `this` is `undefined` in strict mode" -} diff --git a/test/fixtures/transformation/use-strict/illegal-this-root-reference/options.json b/test/fixtures/transformation/use-strict/illegal-this-root-reference/options.json deleted file mode 100644 index 3137168db6..0000000000 --- a/test/fixtures/transformation/use-strict/illegal-this-root-reference/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Top level `this` is `undefined` in strict mode" -} diff --git a/test/fixtures/transformation/use-strict/illegal-this-arrow-function/actual.js b/test/fixtures/transformation/use-strict/undefined-this-arrow-function/actual.js similarity index 100% rename from test/fixtures/transformation/use-strict/illegal-this-arrow-function/actual.js rename to test/fixtures/transformation/use-strict/undefined-this-arrow-function/actual.js diff --git a/test/fixtures/transformation/use-strict/undefined-this-arrow-function/expected.js b/test/fixtures/transformation/use-strict/undefined-this-arrow-function/expected.js new file mode 100644 index 0000000000..bf107937df --- /dev/null +++ b/test/fixtures/transformation/use-strict/undefined-this-arrow-function/expected.js @@ -0,0 +1,5 @@ +"use strict"; + +var foo = function () { + return undefined; +}; \ No newline at end of file diff --git a/test/fixtures/transformation/use-strict/illegal-this-arrow-function/options.json b/test/fixtures/transformation/use-strict/undefined-this-arrow-function/options.json similarity index 100% rename from test/fixtures/transformation/use-strict/illegal-this-arrow-function/options.json rename to test/fixtures/transformation/use-strict/undefined-this-arrow-function/options.json diff --git a/test/fixtures/transformation/use-strict/illegal-this-root-call/actual.js b/test/fixtures/transformation/use-strict/undefined-this-root-call/actual.js similarity index 100% rename from test/fixtures/transformation/use-strict/illegal-this-root-call/actual.js rename to test/fixtures/transformation/use-strict/undefined-this-root-call/actual.js diff --git a/test/fixtures/transformation/use-strict/undefined-this-root-call/expected.js b/test/fixtures/transformation/use-strict/undefined-this-root-call/expected.js new file mode 100644 index 0000000000..269a449b01 --- /dev/null +++ b/test/fixtures/transformation/use-strict/undefined-this-root-call/expected.js @@ -0,0 +1,3 @@ +"use strict"; + +undefined.foo(); \ No newline at end of file diff --git a/test/fixtures/transformation/use-strict/illegal-this-root-declaration/actual.js b/test/fixtures/transformation/use-strict/undefined-this-root-declaration/actual.js similarity index 100% rename from test/fixtures/transformation/use-strict/illegal-this-root-declaration/actual.js rename to test/fixtures/transformation/use-strict/undefined-this-root-declaration/actual.js diff --git a/test/fixtures/transformation/use-strict/undefined-this-root-declaration/expected.js b/test/fixtures/transformation/use-strict/undefined-this-root-declaration/expected.js new file mode 100644 index 0000000000..e9be05fae1 --- /dev/null +++ b/test/fixtures/transformation/use-strict/undefined-this-root-declaration/expected.js @@ -0,0 +1,3 @@ +"use strict"; + +var self = undefined; \ No newline at end of file diff --git a/test/fixtures/transformation/use-strict/illegal-this-root-reference/actual.js b/test/fixtures/transformation/use-strict/undefined-this-root-reference/actual.js similarity index 100% rename from test/fixtures/transformation/use-strict/illegal-this-root-reference/actual.js rename to test/fixtures/transformation/use-strict/undefined-this-root-reference/actual.js diff --git a/test/fixtures/transformation/use-strict/undefined-this-root-reference/expected.js b/test/fixtures/transformation/use-strict/undefined-this-root-reference/expected.js new file mode 100644 index 0000000000..34c5918e4c --- /dev/null +++ b/test/fixtures/transformation/use-strict/undefined-this-root-reference/expected.js @@ -0,0 +1,3 @@ +"use strict"; + +undefined; \ No newline at end of file