From 10d59d2d517ef7103b13a7f9890dcdea13ef8b57 Mon Sep 17 00:00:00 2001 From: Michael Mintz Date: Thu, 7 Sep 2023 17:17:04 -0400 Subject: [PATCH 1/2] Update fragment.bzl to fix bug where "_" was overwritten Update fragment.bzl to fix bug where "_" was overwritten --- javascript/private/fragment.bzl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/javascript/private/fragment.bzl b/javascript/private/fragment.bzl index 05cc0f24dc1f2..9b95038d71e43 100644 --- a/javascript/private/fragment.bzl +++ b/javascript/private/fragment.bzl @@ -54,8 +54,10 @@ def closure_fragment( # own scope on each invocation. wrapper = ( "function(){" + - "return (function(){%output%; return this._.apply(null,arguments);}).apply(" + - "window, arguments);}" + "return (function(){%output%; return this._.apply(null,arguments);}).apply({" + + "navigator:typeof window!='undefined'?window.navigator:null," + + "document:typeof window!='undefined'?window.document:null" + + "}, arguments);}" ) browser_defs = { From be53ad98ef11942c8785da2b4eb4a64b6eed3996 Mon Sep 17 00:00:00 2001 From: Michael Mintz Date: Thu, 7 Sep 2023 20:02:44 -0400 Subject: [PATCH 2/2] Update fragment.bzl (full revert) Update fragment.bzl (full revert) --- javascript/private/fragment.bzl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/javascript/private/fragment.bzl b/javascript/private/fragment.bzl index 9b95038d71e43..d5d6ed1b1d7cb 100644 --- a/javascript/private/fragment.bzl +++ b/javascript/private/fragment.bzl @@ -51,7 +51,12 @@ def closure_fragment( # Wrap the output in two functions. The outer function ensures the # compiled fragment never pollutes the global scope by using its - # own scope on each invocation. + # own scope on each invocation. We must import window.navigator into + # this unique scope since Closure's goog.userAgent package assumes + # navigator and document are defined on goog.global. Normally, this + # would be window, but we are explicitly defining the fragment so that + # goog.global is _not_ window. + # See http://code.google.com/p/selenium/issues/detail?id=1333 wrapper = ( "function(){" + "return (function(){%output%; return this._.apply(null,arguments);}).apply({" +