App-shell or Universal apps are unable to set css variables in document
See original GitHub issueBug Report
Is this a regression?
No
Description
Unable to set css variables in documentElement for app-shell or universal
Minimal Reproduction
https://github.com/richardsengers/theming
ng run app-shell
Exception or Error
ERROR TypeError: Cannot read property 'type' of undefined
at TokenStream.LA (C:\sources\playground\dynamic-theming\dist\dynamic-theming-demo\server\main.js:1204:30)
at TokenStream.advance (C:\sources\playground\dynamic-theming\dist\dynamic-theming-demo\server\main.js:1077:20)
at Parser._readDeclarations (C:\sources\playground\dynamic-theming\dist\dynamic-theming-demo\server\main.js:3796:42)
at Parser.parseStyleAttribute (C:\sources\playground\dynamic-theming\dist\dynamic-theming-demo\server\main.js:3975:22)
at parseStyles (C:\sources\playground\dynamic-theming\dist\dynamic-theming-demo\server\main.js:38557:10)
at CSSStyleDeclaration.value (C:\sources\playground\dynamic-theming\dist\dynamic-theming-demo\server\main.js:38676:22)
at ThemingService.setColorVariable (C:\sources\playground\dynamic-theming\dist\dynamic-theming-demo\server\main.js:57644:45)
at C:\sources\playground\dynamic-theming\dist\dynamic-theming-demo\server\main.js:57546:22
at Array.forEach (<anonymous>)
at C:\sources\playground\dynamic-theming\dist\dynamic-theming-demo\server\main.js:57541:26
at Array.forEach (<anonymous>)
at ThemingService.setupMainPalettes (C:\sources\playground\dynamic-theming\dist\dynamic-theming-demo\server\main.js:57535:45)
at SafeSubscriber._next (C:\sources\playground\dynamic-theming\dist\dynamic-theming-demo\server\main.js:57524:18)
at SafeSubscriber.__tryOrUnsub (C:\sources\playground\dynamic-theming\dist\dynamic-theming-demo\server\main.js:40357:16)
at SafeSubscriber.next (C:\sources\playground\dynamic-theming\dist\dynamic-theming-demo\server\main.js:40296:22)
at Subscriber._next (C:\sources\playground\dynamic-theming\dist\dynamic-theming-demo\server\main.js:40246:26)
Your Environment
Angular Version:
Angular CLI: 11.0.1
Node: 14.17.0
OS: win32 x64
Angular: 11.0.0
... animations, cdk, common, compiler, compiler-cli, core, forms
... material, platform-browser, platform-browser-dynamic, router
Ivy Workspace: Yes
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1100.1
@angular-devkit/build-angular 0.1100.1
@angular-devkit/core 11.0.1
@angular-devkit/schematics 11.0.1
@angular/cli 11.0.1
@angular/platform-server 11.0.9
@schematics/angular 11.0.1
@schematics/update 0.1100.1
rxjs 6.6.3
typescript 4.0.5
Anything else relevant? This has also been described in this issue: https://github.com/angular/angular/issues/36137
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Angular Universal: Complete Practical Guide
This post will be a complete practical guide for getting started with Angular Universal. We are going to go start with an existing...
Read more >Server-side rendering (SSR) with Angular Universal
A Node.js Express web server compiles HTML pages with Universal based on client requests. To create the server-side application module, app.server.module ...
Read more >Implementing A Service Worker For Single-Page App ...
Load an Application Shell (or Appshell) First # ... Instead, we need to load all JavaScript and CSS files from the front end, ......
Read more >Angular workspace configuration
See more in Assets configuration below. styles, An array of style files to add to the global context of the project. Angular CLI...
Read more >Using Webpack Module Federation to Create an App Shell
Challenges of module federation. Likely challenges with pursuing this kind of application architecture include: Single point of failure for ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We needed to make it work in SSR, because the HTML generated from SSR would be otherwise broken due to css vars not applied.
How we managed to make it work (Instead of calling
element.setProperty(xxx, xxx)
):This will ensure the css styles are correctly applied also in the generated html which is returned from SSR.
This indeed appears to be an issue with Domino, which doesn’t support the latest browser features.
Therefore, this is blocked until we switch over to a new JavaScript DOM API. //cc @kyliau