WICG / file-handling

API for web applications to handle files
Other
82 stars 15 forks source link

Consider moving launchQueue off the window object and into navigator #68

Closed alancutter closed 2 years ago

alancutter commented 2 years ago

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 to window.navigator instead as it provides web API namespacing.

alancutter commented 2 years ago

@marcoscaceres mentioned this issue on the launch_handler explainer.

inexorabletash commented 2 years ago

@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...)

domenic commented 2 years ago

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.

alancutter commented 2 years ago

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?

domenic commented 2 years ago

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.

alancutter commented 2 years ago

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.

evanstade commented 2 years ago

seems like this should be moved to https://github.com/WICG/sw-launch/blob/main/launch_handler.md ?