Skip to content

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

@timvdalen

Description

@timvdalen

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

Metadata

Metadata

Assignees

Labels

needs: discussionFurther discussion with the team is needed before proceeding

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions