uzairfarooq / arrive

Watch for DOM elements creation and removal
MIT License
869 stars 99 forks source link

issue when expose arrive API to window #60

Open giannoudak opened 7 years ago

giannoudak commented 7 years ago

hi, and thanks for your wrapper library over Mutation Observers we use arrive.js in one site, and when trying to expose the arrive API in window, we get the error bellow:

// the call in arrive.js line 441:
exposeApi(window.prototype);

// the error:
Uncaught TypeError: Cannot set property 'arrive' of undefined
    at Object.exposeApi (arrive.js:427)
    at eval (eval at <anonymous> (arrive.js:440), <anonymous>:1:1)
    at arrive.js:440
    at Object.r.1 (arrive.js:449)

it seems that the window.prototype is undefined. why this may happen? Is there any way to override this property of window object?

is there any workaround on this? maybe using Window.proto instead will fix it?

uzairfarooq commented 7 years ago

@giannoudak is it specific to some browser. If so, let me know the browser name & version. Also, is your site live, can I check it?

giannoudak commented 7 years ago

@uzairfarooq It isn't for a specific browser. I tried both in chrome and Firefox and the problem is same. You could check this issue at the homepage of the site below. http://www.happyparenting.gr/ Let me know your thoughts.

giannoudak commented 7 years ago

hi @uzairfarooq did you manage to check fo this? thanks in adavance

uzairfarooq commented 7 years ago

Yeah, I had a look into it but not sure what's causing window.prototype to be null, could be some other library. As a workaround you can remove exposeApi(Window.prototype); from the lib.

Will try to have a detailed look when I have some time.

cryptish commented 7 years ago

Window is not defined in PhantomJS (prebuilt, 2.1.14) (running under Karma (0.13.22)).

uzairfarooq commented 4 years ago

We should consider using globalThis (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis) in arrive with appropriate fallbacks.