zserge / lorca

Build cross-platform modern desktop apps in Go + HTML5
MIT License
8.04k stars 535 forks source link

Chance of overriding global functions/variables by mistake #28

Closed awulkan closed 2 years ago

awulkan commented 5 years ago

I don't think it's a good idea to bind functions to the global window object, there's a large chance that people will be overriding browser functionality by naming things the same as existing functionality.

Is there any way to prevent this by default? Maybe everything could be bound to a sub-object of window? So that it could be accessible through something like lorca.myFunction().

peterzen commented 4 years ago

I too am wondering this, having to bind quite a lot of Go functions. Perhaps chrome.bind() could be modified so that it accepts an optional argument, which would specify the global variable to bind() to? Are there any potential issues with this?

https://github.com/zserge/lorca/blob/0261ab7a85a37f49374cf86665bf1dee7b9086ab/chrome.go#L396