Replace raw window references with goog.global.window. (#1818)

This should be safer when run within Node.
This commit is contained in:
Andrew n marshall
2018-05-01 13:35:51 -07:00
committed by GitHub
parent 42e0439aa3
commit 1687275cb2
2 changed files with 5 additions and 3 deletions

View File

@@ -464,7 +464,8 @@ Blockly.bindEventWithChecks_ = function(node, name, thisObject, func,
};
var bindData = [];
if (window && window.PointerEvent && (name in Blockly.Touch.TOUCH_MAP)) {
if (goog.global.window && goog.global.window.PointerEvent &&
(name in Blockly.Touch.TOUCH_MAP)) {
for (var i = 0, type; type = Blockly.Touch.TOUCH_MAP[name][i]; i++) {
node.addEventListener(type, wrapFunc, false);
bindData.push([node, type, wrapFunc]);
@@ -516,7 +517,8 @@ Blockly.bindEvent_ = function(node, name, thisObject, func) {
};
var bindData = [];
if (window && window.PointerEvent && (name in Blockly.Touch.TOUCH_MAP)) {
if (goog.global.window && goog.global.window.PointerEvent &&
(name in Blockly.Touch.TOUCH_MAP)) {
for (var i = 0, type; type = Blockly.Touch.TOUCH_MAP[name][i]; i++) {
node.addEventListener(type, wrapFunc, false);
bindData.push([node, type, wrapFunc]);

View File

@@ -48,7 +48,7 @@ Blockly.Touch.touchIdentifier_ = null;
* @type {Object}
*/
Blockly.Touch.TOUCH_MAP = {};
if (window && window.PointerEvent) {
if (goog.global.window && goog.global.window.PointerEvent) {
Blockly.Touch.TOUCH_MAP = {
'mousedown': ['pointerdown'],
'mouseenter': ['pointerenter'],