YuzuJS/setImmediate

window vs self

Closed this issue · 7 comments

Hi,
is there an exact reason of choosing 'self' over a 'window' object?

I found couple of sites that were using some weird CMS libraries that actually rewrote the 'self' object to their own hence breaking the polyfill and throwing an error about setImmediate not defined.

Is there a way how to bypass this issue?

Thanks in advance.
Kinda desperate :/

self makes it work in web workers.

Thanks for the answer. Makes sense.

This is example of the script with pages where the polyfill breaks.
(window === self -> false)
https://publicwww.com/websites/%22wpdevart_lightbox_front.js%22/

Would it be possible to first check for the window object and if its available use it and then fallback for the 'self', etc...

Just idea.

There are an infinite number of things people could mess up in their environment to break this library; I don't think we should treat this one specially.

Yeah, I guess you are right.

Cannot make everyone happy :D

I don't see nothing bad in

var self = self.window || self.self

It will be quite cheep improvement. @domenic If there will be a PR would you approve it?

No.

This is why "Fork" was invented.