Skip to content

Commit

Permalink
build: fix error from latest MDC canary (#21663)
Browse files Browse the repository at this point in the history
The latest MDC canary version introduced its own types for `ResizeObserver` which broke
our code. These changes remove the polyfilled types and use MDC's instead.

(cherry picked from commit acb3f33)
  • Loading branch information
crisbeto authored and andrewseguin committed Jan 21, 2021
1 parent b270f5a commit f8c3597
Show file tree
Hide file tree
Showing 6 changed files with 605 additions and 605 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"@types/youtube": "^0.0.40",
"@webcomponents/custom-elements": "^1.1.0",
"core-js-bundle": "^3.8.2",
"material-components-web": "10.0.0-canary.b2faa116a.0",
"material-components-web": "10.0.0-canary.2ed2d829b.0",
"rxjs": "^6.5.3",
"rxjs-tslint-rules": "^4.33.1",
"systemjs": "0.19.43",
Expand Down Expand Up @@ -107,7 +107,6 @@
"@types/node": "^14.14.22",
"@types/node-fetch": "^2.5.5",
"@types/parse5": "^6.0.0",
"@types/resize-observer-browser": "^0.1.3",
"@types/semver": "^7.3.4",
"@types/send": "^0.14.5",
"@types/stylelint": "^9.10.1",
Expand Down
1 change: 0 additions & 1 deletion src/material-experimental/mdc-progress-bar/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ ng_module(
"//src/material/progress-bar",
"@npm//@angular/core",
"@npm//@material/linear-progress",
"@npm//@types/resize-observer-browser",
],
)

Expand Down
17 changes: 12 additions & 5 deletions src/material-experimental/mdc-progress-bar/progress-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ import {
import {CanColor, CanColorCtor, mixinColor} from '@angular/material-experimental/mdc-core';
import {ANIMATION_MODULE_TYPE} from '@angular/platform-browser/animations';
import {ProgressAnimationEnd} from '@angular/material/progress-bar';
import {MDCLinearProgressAdapter, MDCLinearProgressFoundation} from '@material/linear-progress';
import {
MDCLinearProgressAdapter,
MDCLinearProgressFoundation,
WithMDCResizeObserver,
} from '@material/linear-progress';
import {Subscription, fromEvent, Observable} from 'rxjs';
import {filter} from 'rxjs/operators';
import {Directionality} from '@angular/cdk/bidi';
Expand Down Expand Up @@ -93,10 +97,13 @@ export class MatProgressBar extends _MatProgressBarMixinBase implements AfterVie
},
getWidth: () => this._rootElement.offsetWidth,
attachResizeObserver: (callback) => {
if ((typeof window !== 'undefined') && window.ResizeObserver) {
const ro = new ResizeObserver(callback);
ro.observe(this._rootElement);
return ro;
const resizeObserverConstructor = (typeof window !== 'undefined') &&
(window as unknown as WithMDCResizeObserver).ResizeObserver;

if (resizeObserverConstructor) {
const observer = new resizeObserverConstructor(callback);
observer.observe(this._rootElement);
return observer;
}

return null;
Expand Down
2 changes: 1 addition & 1 deletion src/material-experimental/tsconfig-tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"importHelpers": false,
"module": "umd",
"target": "es5",
"types": ["jasmine", "resize-observer-browser"],
"types": ["jasmine"],
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"paths": {
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"strictBindCallApply": true,
"target": "es2015",
"lib": ["es5", "es2015", "dom"],
"types": ["jasmine", "resize-observer-browser"],
"types": ["jasmine"],
"baseUrl": ".",
"paths": {
"@angular/cdk": ["./src/cdk"],
Expand Down
Loading

0 comments on commit f8c3597

Please sign in to comment.