-
Notifications
You must be signed in to change notification settings - Fork 108
Support running inside a Web Worker #60
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
base: master
Are you sure you want to change the base?
Conversation
…ndow nor document there), in Chrome
@@ -12,7 +12,7 @@ | |||
, attachEvent = 'attachEvent' | |||
, removeEvent = 'removeEventListener' | |||
, detachEvent = 'detachEvent' | |||
, doc = document || {} | |||
, doc = typeof document !== 'undefined' ? document : {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does document || {}
not do the right thing in a worker?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no. try doing a = thisvardoesnotexist || {};
in the Chrome Javascript console :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh ya, of course.
Interesting use case. I'm wondering how you're using Bean in a WebWorker? Are you listening to browser events or using it for pubsub? If the aim of this PR is to add WW support perhaps some tests for that would be neat if you can manage it. |
I'd like to extend this request to node.js; bean.js assumes some global objects like |
It makes sense to include the checks. var doc = typeof document !== 'undefined' && document |
I'd like to see some tests for some of this, anyone got time and ideas for testing in webworkers and/or testing in node? |
Support running from loadScript() inside a Web Worker (there is no window nor document there), in Chrome.