From 6080ab547dfed08108f0aa154e31a94f94d4ddcb Mon Sep 17 00:00:00 2001 From: Ben Alpert Date: Sat, 4 Jun 2016 13:37:57 -0700 Subject: [PATCH] Fix function declaration in if statement (#6963) Firefox doesn't like these and throws. (cherry picked from commit 3c3c30a19a25fd542861e97f197d22b8f4c586de) --- .eslintrc.js | 1 + scripts/bench/extract-component.js | 4 ++-- src/isomorphic/classic/element/ReactElement.js | 8 ++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index a099d6bfca..f4773f28f2 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -30,6 +30,7 @@ module.exports = { 'indent': [ERROR, 2, {SwitchCase: 1}], 'jsx-quotes': [ERROR, 'prefer-double'], 'no-bitwise': OFF, + 'no-inner-declarations': [ERROR, 'functions'], 'no-multi-spaces': ERROR, 'no-restricted-syntax': [ERROR, 'WithStatement'], 'no-shadow': ERROR, diff --git a/scripts/bench/extract-component.js b/scripts/bench/extract-component.js index 3dfda0c252..36bcf4d1c6 100644 --- a/scripts/bench/extract-component.js +++ b/scripts/bench/extract-component.js @@ -112,7 +112,7 @@ function print(outerComponent) { var values = keys.map((childKey) => renderedChildren[childKey]); if (keys.length) { - function dump(children) { + var dump = function(children) { if (typeof children === 'boolean' || children == null) { return '' + children; } @@ -130,7 +130,7 @@ function print(outerComponent) { debugger; throw new Error('hmm'); } - } + }; markup += '\n'; var children = element.props.children; diff --git a/src/isomorphic/classic/element/ReactElement.js b/src/isomorphic/classic/element/ReactElement.js index 98af361b09..86ca0c9aa5 100644 --- a/src/isomorphic/classic/element/ReactElement.js +++ b/src/isomorphic/classic/element/ReactElement.js @@ -210,7 +210,7 @@ ReactElement.createElement = function(type, config, children) { type; // Create dummy `key` and `ref` property to `props` to warn users against its use - function warnAboutAccessingKey() { + var warnAboutAccessingKey = function() { if (!specialPropKeyWarningShown) { specialPropKeyWarningShown = true; warning( @@ -223,10 +223,10 @@ ReactElement.createElement = function(type, config, children) { ); } return undefined; - } + }; warnAboutAccessingKey.isReactWarning = true; - function warnAboutAccessingRef() { + var warnAboutAccessingRef = function() { if (!specialPropRefWarningShown) { specialPropRefWarningShown = true; warning( @@ -239,7 +239,7 @@ ReactElement.createElement = function(type, config, children) { ); } return undefined; - } + }; warnAboutAccessingRef.isReactWarning = true; if (typeof props.$$typeof === 'undefined' ||