Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better global namespace names for addons #2015

Closed
cubiclesoft opened this issue Apr 14, 2019 · 1 comment
Closed

Better global namespace names for addons #2015

cubiclesoft opened this issue Apr 14, 2019 · 1 comment

Comments

@cubiclesoft
Copy link
Contributor

When loading an addon, the global window namespace is "polluted" with the addon name (e.g. the fit addon exports as window.fit). I know language purists balk at the idea of global namespace pollution but personally, as long as code works, I don't care. However, the addon export names are fairly generic (e.g. attach, fit, fullscreen, search). As a result, there's an increased likelihood that other code that also uses the global namespace could stomp on the exported addon before the Terminal.applyAddon() call is made (or vice versa - the addon could stomp on a global with the same name). If the exported names were prefixed or placed into an object named xtermAddons or something along those lines, it would reduce the chance of another piece of software declaring a global variable somewhere in their code with the same name as an addon here.

Standalone, this would be a breaking change. A possible route to take could be to add a namespaced export to the existing export, encourage users to move over to the new "no conflict" export mechanism via the docs/examples, and maybe remove the old export names sometime in the future.

@Tyriar
Copy link
Member

Tyriar commented Apr 14, 2019

This should be fixed as part of #1128 as we're not planning on adding the addons to window

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants