Skip to content
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

addEventListener beforeunload not working #445

Closed
pasviegas opened this issue Mar 11, 2014 · 11 comments · Fixed by googlearchive/ShadowDOM#403
Closed

addEventListener beforeunload not working #445

pasviegas opened this issue Mar 11, 2014 · 11 comments · Fixed by googlearchive/ShadowDOM#403
Assignees

Comments

@pasviegas
Copy link

Hey, I am using a external library that uses setInterval and adds a beforeunload listener to clean it before leaving the page. But thats not happening, so it is causing the user to be prompted a message before leaving.

It seems that polymer is overriding the addEventListener and not firing the beforeunload properly.

Is it a known issue? Is there any fix?

Thanks a lot.

@arv
Copy link
Contributor

arv commented Mar 12, 2014

Are you setting eventObject.returnValue or are you doing it differently?

@pasviegas
Copy link
Author

This is the function which is called:

function(a) {
        try {
            if (!this.id) {
                return
            }
            var b = this.opaqueElement;
            if (this.isIgnored(b)) {
                return
            }
            if (b) {
                this.click(b);
                this.opaqueElement = null
            }
        } catch (c) {}
    }

Thanks! =)

@arv
Copy link
Contributor

arv commented Mar 13, 2014

I don't see where you are setting returnValue? Can you provide a test case (jsbin)?

@pasviegas
Copy link
Author

Actually, it's a third party library that is adding the listener and it only works in the right domain. So I don't think I can properly make a jsbin.

But if I remove polymer it works.. =T

@arv
Copy link
Contributor

arv commented Mar 13, 2014

Does it work in Firefox without polymer? (Chrome used to have an extension to addEventListener)

@arv arv self-assigned this Mar 13, 2014
@arv
Copy link
Contributor

arv commented Mar 13, 2014

I can reproduce weirdness... not the same issue as you are seeing though. I get "false" instead of the string that I want.

@pasviegas
Copy link
Author

Yep, I am getting false too =)

Seems that it happens only in chrome and safari..

@arv
Copy link
Contributor

arv commented Mar 13, 2014

I can explain the false one. That is Chrome doing the wrong thing with the return value. I noticed that BeforeUnloadEvent was never registered.

I'm debugging now. I expect to have this fixed today.

@pasviegas
Copy link
Author

I am trying to test it and see if it works for me, how can I use your pr?

@dfreedm
Copy link
Member

dfreedm commented Mar 14, 2014

@pasviegas Just merged this in, sorry for the delay.

@pasviegas
Copy link
Author

Working, thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants