Skip to content

Commit b687c7b

Browse files
authored
[atoms] Update fragment.bzl to fix a bug where "_" was overwritten (#12704)
* Update fragment.bzl to fix bug where "_" was overwritten Update fragment.bzl to fix bug where "_" was overwritten * Update fragment.bzl (full revert) Update fragment.bzl (full revert)
1 parent e518273 commit b687c7b

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

javascript/private/fragment.bzl

+10-3
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,18 @@ def closure_fragment(
5151

5252
# Wrap the output in two functions. The outer function ensures the
5353
# compiled fragment never pollutes the global scope by using its
54-
# own scope on each invocation.
54+
# own scope on each invocation. We must import window.navigator into
55+
# this unique scope since Closure's goog.userAgent package assumes
56+
# navigator and document are defined on goog.global. Normally, this
57+
# would be window, but we are explicitly defining the fragment so that
58+
# goog.global is _not_ window.
59+
# See http://code.google.com/p/selenium/issues/detail?id=1333
5560
wrapper = (
5661
"function(){" +
57-
"return (function(){%output%; return this._.apply(null,arguments);}).apply(" +
58-
"window, arguments);}"
62+
"return (function(){%output%; return this._.apply(null,arguments);}).apply({" +
63+
"navigator:typeof window!='undefined'?window.navigator:null," +
64+
"document:typeof window!='undefined'?window.document:null" +
65+
"}, arguments);}"
5966
)
6067

6168
browser_defs = {

0 commit comments

Comments
 (0)