Skip to content

Commit

Permalink
Add (<any>window) before matchMedia
Browse files Browse the repository at this point in the history
  • Loading branch information
tinayuangao authored Aug 3, 2017
1 parent 7311f99 commit 8f5330e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/media-query/match-media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export class MatchMedia {
protected _buildMQL(query: string): MediaQueryList {
let canListen = isBrowser() && !!(<any>window).matchMedia('all').addListener;

return canListen ? matchMedia(query) : <MediaQueryList>{
return canListen ? (<any>window).matchMedia(query) : <MediaQueryList>{
matches: query === 'all' || query === '',
media: query,
addListener: () => {
Expand Down

2 comments on commit 8f5330e

@ardatan
Copy link

@ardatan ardatan commented on 8f5330e Aug 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would you need that? matchMedia is already a global function.

@ThomasBurleson
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Closure compiler fails without global window prefix; angular universal ignores this as isBrowser() == false on SSR.

Please sign in to comment.