Closed alancutter closed 2 years ago
@marcoscaceres mentioned this issue on the launch_handler explainer.
@domenic has thoughts about window
vs. navigator
. Likely the TAG too.
In theory, JS variables shadow anything newly added to window
very intentionally to avoid this problem. (via WindowProxy? I forget the details...)
Definitely prefer window
instead of using navigator
as a dumping ground. We've successfully launched many properties of Window (886 by my count) without a serious collision issue.
Ack. What's the intended purpose of navigator
? Is it a place to put things if they do happen to collide with existing JS code?
It's best used for things like navigator.userAgent, navigator.oscpu, etc. But it also turned into a bit of a dumping ground for some unclear reason.
I suspect in the absence of an intentional web API namespacing object (e.g. window.web
) to avoid the collision issue we ended up using navigator
.
seems like this should be moved to https://github.com/WICG/sw-launch/blob/main/launch_handler.md ?
Adding new member to the
window
object has the risk of breaking existing JavaScript code that uses the same variable name. We should consider adding it towindow.navigator
instead as it provides web API namespacing.