Skip to content

Cannot read property 'style' of null #281

@MaklaCof

Description

@MaklaCof

First, I already try to find solution on SO, but I think this is a bug.

I am using Angular2 application. (For backend I use ASP.NET core 1.1.) I also create SignIn button following official tutorial.

On successfully log in I re-route user to home page and then I get error. I get the same error if I logout from google account (in chrome).

The error is:

vendor.js:81139 Uncaught TypeError: Cannot read property 'style' of null
at G_ (cb=gapi.loaded_1:91)
at H_. (cb=gapi.loaded_1:94)
at Function. (cb=gapi.loaded_0:155)
at run (vendor.js:99289)
at runIfPresent (vendor.js:99318)
at onGlobalMessage (vendor.js:99358)
at ZoneDelegate.invokeTask (vendor.js:81259)
at Zone.runTask (vendor.js:81135)
at ZoneTask.invoke (vendor.js:81329)

and line with error is:
window.document.getElementById((c?"not_signed_in":"connected")+a.El).style.display="none";
Of course getElementById returns null, because I am no longer on Login page, and Angular remove html from DOM. Same happens if I log out from Google account. The user could be anywhere.

I read somewhere on SO, where tip for same error was

don't delete Google SignIn element, just set diplay to none

, but this is not possible here, since Angular2 remove element from DOM.

I think you should check first if element exists and then set style to whatever.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions