From eae82799e6ee61d68c3ca98fc9f9680c1424c66f Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Tue, 15 Sep 2015 06:16:57 +0100 Subject: [PATCH] loop over all directives to check for use strict --- packages/babylon/src/parser/expression.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/babylon/src/parser/expression.js b/packages/babylon/src/parser/expression.js index d38d50ea27..391981ae28 100644 --- a/packages/babylon/src/parser/expression.js +++ b/packages/babylon/src/parser/expression.js @@ -793,9 +793,14 @@ pp.parseFunctionBody = function (node, allowExpression) { if (allowExpression) checkLVal = true; // normal function - if (!isExpression && node.body.body.length && this.isUseStrict(node.body.body[0])) { - checkLVal = true; - checkLValStrict = true; + if (!isExpression && node.body.directives.length) { + for (var directive of (node.body.directives: Array)) { + if (directive.value === "use strict") { + checkLVal = true; + checkLValStrict = true; + break; + } + } } if (checkLVal) {