-
Notifications
You must be signed in to change notification settings - Fork 207
Open
Description
This library is very useful and I would like to use it for service workers too. I noticed that it uses window object to attach detect to it. window object is inaccessible in service workers, but we can use this to achieve the same results.
I implemented and tested this solution:
Instead of passing window object to the function directly:
(function(root, undefined) {
// function body
})(window);We can check first if window is undefined which means we run this library in a service worker. If so we can use this instead:
(function(root, undefined) {
// function body
})(typeof window == 'undefined' ? this : window);Metadata
Metadata
Assignees
Labels
No labels