question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

hasV8BreakIterator breaks in environments without window (such as universal rendering)

See original GitHub issue

Bug, 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:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
devversioncommented, Dec 11, 2016

I think this issue is more complicated than it looks.

The MdPlatform service also uses the navigator object to detect the different platforms.

This will lead to a Runtime Exception in Universal.

cc. @jelbourn

0reactions
angular-automatic-lock-bot[bot]commented, Sep 5, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Does this work with server side rendering? no 'window' or ...
It seems I have 3 slides, but the first slide never shows - it starts on the second slide. In addition if I...
Read more >
Installing the Universal Render Pipeline into an existing Project
Installing URP. In Unity, open your Project. In the top navigation bar, select Window > Package Manager to open the Package Manager window....
Read more >
Don't let Angular Universal break you (or your app). Some tips ...
Don't let Angular Universal break you (or your app). Some tips to keep your sanity. Server Side Rendering (SSR) is not without its...
Read more >
Evolving game graphics with the Universal Render Pipeline
Take your cross-platform game visuals to the next level. This video goes in-Editor to show you how to use some of the newest...
Read more >
Upgrading your existing project to Universal Render Pipeline
The Universal Render Pipeline brings with it long-awaited accessibility and performance improvements to rendering in Unity.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found