Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
timvdalen opened this issue Dec 11, 2016 · 5 comments
Assignees
Labels
needs: discussion Further discussion with the team is needed before proceeding

Comments

@timvdalen
Copy link
Contributor

Bug, feature request, or proposal:

Bug: As of #1950, @angular/material no longer works with server-side rendering because 4b7e52d#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 #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

@devversion devversion self-assigned this Dec 11, 2016
@devversion
Copy link
Member

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

@timvdalen
Copy link
Contributor Author

Ah, we haven't run in to that since we're only using MdDialog and it's never rendered on the server side.
For our use case, hasV8BreakIterator is the only thing that's reached that expects a browser environment

@devversion
Copy link
Member

Ah I see - I will take a look at this as soon as possible.

@devversion
Copy link
Member

Just discussed this with the team. We are going to track this issue with #308

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 5, 2019
@mmalerba mmalerba added the needs: discussion Further discussion with the team is needed before proceeding label Mar 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs: discussion Further discussion with the team is needed before proceeding
Projects
None yet
Development

No branches or pull requests

3 participants