Skip to content

Commit

Permalink
Merge pull request facebook#287 from spicyj/noglobal
Browse files Browse the repository at this point in the history
Remove all uses of ExecutionEnvironment.global
  • Loading branch information
yungsters committed Sep 9, 2013
2 parents 888cc30 + 426cdbb commit aa765e8
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 18 deletions.
3 changes: 1 addition & 2 deletions src/core/ReactEventTopLevelCallback.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

"use strict";

var ExecutionEnvironment = require('ExecutionEnvironment');
var ReactEventEmitter = require('ReactEventEmitter');
var ReactMount = require('ReactMount');

Expand Down Expand Up @@ -74,7 +73,7 @@ var ReactEventTopLevelCallback = {
}
var topLevelTarget = ReactMount.getFirstReactDOM(
getEventTarget(nativeEvent)
) || ExecutionEnvironment.global;
) || window;
var topLevelTargetID = ReactMount.getID(topLevelTarget) || '';
ReactEventEmitter.handleTopLevel(
topLevelType,
Expand Down
7 changes: 1 addition & 6 deletions src/dom/getEventTarget.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

"use strict";

var ExecutionEnvironment = require('ExecutionEnvironment');

/**
* Gets the target node from a native browser event by accounting for
* inconsistencies in browser DOM APIs.
Expand All @@ -29,10 +27,7 @@ var ExecutionEnvironment = require('ExecutionEnvironment');
* @return {DOMEventTarget} Target node.
*/
function getEventTarget(nativeEvent) {
var target =
nativeEvent.target ||
nativeEvent.srcElement ||
ExecutionEnvironment.global;
var target = nativeEvent.target || nativeEvent.srcElement || window;
// Safari may fire events on text nodes (Node.TEXT_NODE is 3).
// @see http://www.quirksmode.org/js/events_properties.html
return target.nodeType === 3 ? target.parentNode : target;
Expand Down
5 changes: 2 additions & 3 deletions src/eventPlugins/EnterLeaveEventPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

var EventConstants = require('EventConstants');
var EventPropagators = require('EventPropagators');
var ExecutionEnvironment = require('ExecutionEnvironment');
var SyntheticMouseEvent = require('SyntheticMouseEvent');

var ReactMount = require('ReactMount');
Expand Down Expand Up @@ -75,9 +74,9 @@ var EnterLeaveEventPlugin = {
from = topLevelTarget;
to =
getFirstReactDOM(nativeEvent.relatedTarget || nativeEvent.toElement) ||
ExecutionEnvironment.global;
window;
} else {
from = ExecutionEnvironment.global;
from = window;
to = topLevelTarget;
}

Expand Down
5 changes: 1 addition & 4 deletions src/test/ReactPerf.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,7 @@ var ReactPerf = {

if (__DEV__) {
var ExecutionEnvironment = require('ExecutionEnvironment');
var URL = ExecutionEnvironment.global &&
ExecutionEnvironment.global.location &&
ExecutionEnvironment.global.location.href ||
'';
var URL = ExecutionEnvironment.canUseDOM ? window.location.href : '';
ReactPerf.enableMeasure = ReactPerf.enableMeasure ||
!!URL.match(/[?&]react_perf\b/);
}
Expand Down
4 changes: 1 addition & 3 deletions src/vendor/core/ExecutionEnvironment.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ var ExecutionEnvironment = {

canUseWorkers: typeof Worker !== 'undefined',

isInWorker: !canUseDOM, // For now, this is true - might change in the future.

global: new Function('return this;')()
isInWorker: !canUseDOM // For now, this is true - might change in the future.

};

Expand Down

0 comments on commit aa765e8

Please sign in to comment.