hasV8BreakIterator breaks in environments without window (such as universal rendering)
See original GitHub issueBug, feature request, or proposal:
Bug: As of https://github.com/angular/material2/pull/1950, @angular/material
no longer works with server-side rendering because https://github.com/angular/material2/commit/4b7e52d30aa342c3024ed078837a9bd4ca9e773b#diff-6d0e189ed8a75860045a39fe4c576374R7 expects window to be defined.
What is the expected behavior?
No errors when loading the module
What is the current behavior?
node_modules\@angular\material\material.umd.js:2028
var hasV8BreakIterator = (window.Intl && window.Intl.v8BreakIterator);
^
ReferenceError: window is not defined
What are the steps to reproduce?
Loading the module in a https://github.com/angular/universal project
What is the use-case or motivation for changing an existing behavior?
PR https://github.com/angular/material2/pull/1950 broke compatibility with node
Which versions of Angular, Material, OS, browsers are affected?
Running on node
Is there anything else we should know?
As a temporary fix, changing the line to const hasV8BreakIterator = ((typeof window !== 'undefined') && window.Intl && (window.Intl as any).v8BreakIterator);
seems to work, but I’m not sure what that means for this platform check since node does have th v8 break iterator.
/cc @sattip
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:5 (4 by maintainers)
Top GitHub Comments
I think this issue is more complicated than it looks.
The
MdPlatform
service also uses thenavigator
object to detect the different platforms.cc. @jelbourn
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.