ReferenceError: Document is not defined
See original GitHub issueI am using angular universal for server side rendering, prior to the upgrade to angular 8 everything was working fine, however after the upgrade, whenever i compile and try to run the server file code, it gives me that Document is not defined error. I’m wondering if you’re directly using the Document object directly somewhere in the library.
... __param(6, core_1.Inject(common_1.DOCUMENT)), __metadata("design:paramtypes", [core_1.ElementRef, core_1.Renderer, lightbox_event_service_1.LightboxEvent, core_1.ElementRef, lightbox_event_service_1.LightboxWindowRef, platform_browser_1.DomSanitizer, Document]) ], LightboxComponent); return LightboxComponent; }()); exports.LightboxComponent = LightboxComponent;
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:33 (19 by maintainers)
Top GitHub Comments
@themyth92 I was able to compile my server side rendering code without the error from your node module. It appears that the PR worked in my case. Thanks for hearing us out and getting it out there. @cozzbie Thanks for taking a look at this and getting it handled.
@themyth92, below is the error im getting:
`/Users/myfolder/Desktop/apps/myapp/build/server.js:139193 Document]) ^
ReferenceError: Document is not defined at /Users/myfolder/Desktop/apps/myapp/build/server.js:139193:13 at Object…/node_modules/ngx-lightbox/lightbox.component.js (/Users/myfolder/Desktop/apps/myapp/build/server.js:139196:2) at webpack_require (/Users/myfolder/Desktop/apps/myapp/build/server.js:138086:30) at Module…/node_modules/ngx-lightbox/lightbox.component.ngfactory.js (/Users/myfolder/Desktop/apps/myapp/build/server.js:139217:77)`
This is the code when i dig into server.js:139193
LightboxComponent = __decorate([ core_1.Component({ template: "\n <div class=\"lb-outerContainer transition\" #outerContainer>\n <div class=\"lb-container\" #container>\n <img class=\"lb-image\" [src]=\"album[currentImageIndex].src\" class=\"lb-image animation fadeIn\" [hidden]=\"ui.showReloader\" #image>\n <div class=\"lb-nav\" [hidden]=\"!ui.showArrowNav\" #navArrow>\n <a class=\"lb-prev\" [hidden]=\"!ui.showLeftArrow\" (click)=\"prevImage()\" #leftArrow></a>\n <a class=\"lb-next\"[hidden]=\"!ui.showRightArrow\" (click)=\"nextImage()\" #rightArrow></a>\n </div>\n <div class=\"lb-loader\" [hidden]=\"!ui.showReloader\" (click)=\"close($event)\">\n <a class=\"lb-cancel\"></a>\n </div>\n </div>\n </div>\n <div class=\"lb-dataContainer\" [hidden]=\"ui.showReloader\" #dataContainer>\n <div class=\"lb-data\">\n <div class=\"lb-details\">\n <span class=\"lb-caption animation fadeIn\" [hidden]=\"!ui.showCaption\" [innerHtml]=\"album[currentImageIndex].caption\" #caption>\n </span>\n <span class=\"lb-number animation fadeIn\" [hidden]=\"!ui.showPageNumber\" #number>{{ content.pageNumber }}</span>\n </div>\n <div class=\"lb-closeContainer\">\n <a class=\"lb-close\" (click)=\"close($event)\"></a>\n </div>\n </div>\n </div>", selector: '[lb-content]', host: { '(click)': 'close($event)', '[class]': 'ui.classList' } }), __param(6, core_1.Inject(common_1.DOCUMENT)), __metadata("design:paramtypes", [core_1.ElementRef, core_1.Renderer, lightbox_event_service_1.LightboxEvent, core_1.ElementRef, lightbox_event_service_1.LightboxWindowRef, platform_browser_1.DomSanitizer, Document]) ], LightboxComponent); return LightboxComponent; }()); exports.LightboxComponent = LightboxComponent; //# sourceMappingURL=lightbox.component.js.map
This snippet towards the bottom is the line its complaining about (Document):