Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

window.addEventListener is undefined in IE right after opening new window #535

@marcovdb

Description

@marcovdb

I'm submitting a ... (check one with "x")

[*] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior
In one part of my application I open up a new window using window.open, but I want to attach some code to the window's beforeclose event (because I need to refresh some data on the page). Window.open returns a reference to the window object, but in IE if I access the reference right after opening the window the addEventListener method is undefined. If I wrap it in a short timeout it's usually OK, but this feels hackish an unreliable to me.

My current guess it's because Zone.js monkey-patches the addEventListener function and it's taking some time in IE.

Expected behavior
window.open should return a complete reference to the window object, with all of its methods intact.

Minimal reproduction of the problem with instructions

Check the following Plunker in IE and in Chrome (or any other browser, really) and observe the difference.
https://plnkr.co/edit/FbvnWDdaN5aheFZG7PDC?p=preview

What is the motivation / use case for changing the behavior?
We should be able to reliably access a newly opened window's object.

Please tell us about your environment:

  • Browser: Internet Explorer 11

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions