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

Angular Universal (Angular 8, 12.2.0) null window/document reference #205

Closed
coenmooij opened this issue Aug 20, 2019 · 6 comments
Closed
Labels

Comments

@coenmooij
Copy link
Contributor

When adding Angular Universal to my Angular 8 app, I'm getting this error when I refresh on a page where I've included the clipboard directive.

TypeError: Cannot read property 'document' of null
    at ClipboardService.destroy (/project/dist/server.js:161333:61)
    at ClipboardDirective.ngOnDestroy (/project/dist/server.js:161488:27)
    at callProviderLifecycles (project/dist/server.js:24510:18)
    at callElementProvidersLifecycles (/project/dist/server.js:24478:13)
    at callLifecycleHooksChildrenFirst (/project/dist/server.js:24468:29)
    at destroyView (/project/dist/server.js:32664:5)
    at callViewAction (/project/dist/server.js:32790:13)
    at execComponentViewsAction (/project/dist/server.js:32712:13)
    at destroyView (/project/dist/server.js:32663:5)
    at callViewAction (/project/dist/server.js:32790:13)

Referring to this line of code:

public destroy(container: HTMLElement = this.window.document.body) {

Is there a reason it's not using this.document instead of this.window.document?

The same happens one more time a little bit earlier in the file:

public copyFromContent(content: string, container: HTMLElement = this.window.document.body) {

@maxisam
Copy link
Owner

maxisam commented Aug 20, 2019

I think you are correct. We should use this.document instead. Do you want to create a pull request?

@maxisam maxisam added the bug label Aug 20, 2019
@coenmooij
Copy link
Contributor Author

will do @maxisam 👍

@coenmooij
Copy link
Contributor Author

Done, Check #206

@maxisam
Copy link
Owner

maxisam commented Aug 20, 2019

please try 12.2.1-beta.2

@coenmooij
Copy link
Contributor Author

Didn't have a lot of time past days, but I just checked it, and glad to report it solved the issue.
Thanks for the fast help! @maxisam

@maxisam
Copy link
Owner

maxisam commented Aug 22, 2019

@coenmooij no problem. Thank you for making a pull request.

@maxisam maxisam closed this as completed Aug 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants