@@ -11,7 +11,7 @@ destroyed until the next render. Next, the server environment inherently does no
1111same capabilities as the browser (and has some that likewise the browser does not). For
1212instance, the server does not have any concept of cookies. You can polyfill this and other
1313functionality, but there is no perfect solution for this. In later sections, we'll walk
14- through potential mitigations to reduce the error plane when rendering on the server.
14+ through potential mitigations to reduce the scope of errors when rendering on the server.
1515
1616Please also note the goal of SSR: improved initial render time for your application. This
1717means that anything that has the potential to reduce the speed of your application in this
@@ -25,7 +25,7 @@ variables in the server environment. This is because the Universal project uses
2525[ domino] ( https://github.com/fgnass/domino ) as the server DOM rendering engine. As a result,
2626there is certain functionality that won't be present or supported on the server. This
2727includes the ` window ` and ` document ` global objects, cookies, certain HTML elements (like canvas),
28- and several others. There is no exhaustive list, so please be cognizant of the fact that if you
28+ and several others. There is no exhaustive list, so please be aware of the fact that if you
2929see an error like this, where a previously-accessible global is not defined, it's likely because
3030that global is not available through domino.
3131
@@ -76,8 +76,12 @@ often invocations of the global `window` element are to get window size, or some
7676However, on the server, there is no concept of "screen", and so this functionality is rarely needed.
7777
7878You may read online and elsewhere that the recommended approach is to use ` isPlatformBrowser ` or
79- ` isPlatformServer ` . This guidance is ** incorrect** . Instead, you should use Angular's Dependency Injection (DI)
80- in order to remove the offending code and drop in a replacement at runtime. Here's an example:
79+ ` isPlatformServer ` . This guidance is ** incorrect** . This is because you wind up creating platform-specific
80+ code branches in your application code. This not only increases the size of your application unnecessarily,
81+ but it also adds complexity that then has to be maintained. By separating code into separate platform-specific
82+ modules and implementations, your base code can remain about business logic, and platform-specific exceptions
83+ are handled as they should be: on a case-by-case abstraction basis. This can be accomplished using Angular's Dependency
84+ Injection (DI) in order to remove the offending code and drop in a replacement at runtime. Here's an example:
8185
8286``` ts
8387// window-service.ts
0 commit comments