Skip to content

Commit acb3f33

Browse files
authored
build: fix error from latest MDC canary (#21663)
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.
1 parent 9190785 commit acb3f33

File tree

6 files changed

+605
-605
lines changed

6 files changed

+605
-605
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"@types/youtube": "^0.0.40",
6464
"@webcomponents/custom-elements": "^1.1.0",
6565
"core-js-bundle": "^3.8.2",
66-
"material-components-web": "10.0.0-canary.b2faa116a.0",
66+
"material-components-web": "10.0.0-canary.2ed2d829b.0",
6767
"rxjs": "^6.5.3",
6868
"rxjs-tslint-rules": "^4.33.1",
6969
"systemjs": "0.19.43",
@@ -107,7 +107,6 @@
107107
"@types/node": "^14.14.22",
108108
"@types/node-fetch": "^2.5.5",
109109
"@types/parse5": "^6.0.0",
110-
"@types/resize-observer-browser": "^0.1.3",
111110
"@types/semver": "^7.3.4",
112111
"@types/send": "^0.14.5",
113112
"@types/stylelint": "^9.10.1",

src/material-experimental/mdc-progress-bar/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ ng_module(
2727
"//src/material/progress-bar",
2828
"@npm//@angular/core",
2929
"@npm//@material/linear-progress",
30-
"@npm//@types/resize-observer-browser",
3130
],
3231
)
3332

src/material-experimental/mdc-progress-bar/progress-bar.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ import {
2323
import {CanColor, CanColorCtor, mixinColor} from '@angular/material-experimental/mdc-core';
2424
import {ANIMATION_MODULE_TYPE} from '@angular/platform-browser/animations';
2525
import {ProgressAnimationEnd} from '@angular/material/progress-bar';
26-
import {MDCLinearProgressAdapter, MDCLinearProgressFoundation} from '@material/linear-progress';
26+
import {
27+
MDCLinearProgressAdapter,
28+
MDCLinearProgressFoundation,
29+
WithMDCResizeObserver,
30+
} from '@material/linear-progress';
2731
import {Subscription, fromEvent, Observable} from 'rxjs';
2832
import {filter} from 'rxjs/operators';
2933
import {Directionality} from '@angular/cdk/bidi';
@@ -93,10 +97,13 @@ export class MatProgressBar extends _MatProgressBarMixinBase implements AfterVie
9397
},
9498
getWidth: () => this._rootElement.offsetWidth,
9599
attachResizeObserver: (callback) => {
96-
if ((typeof window !== 'undefined') && window.ResizeObserver) {
97-
const ro = new ResizeObserver(callback);
98-
ro.observe(this._rootElement);
99-
return ro;
100+
const resizeObserverConstructor = (typeof window !== 'undefined') &&
101+
(window as unknown as WithMDCResizeObserver).ResizeObserver;
102+
103+
if (resizeObserverConstructor) {
104+
const observer = new resizeObserverConstructor(callback);
105+
observer.observe(this._rootElement);
106+
return observer;
100107
}
101108

102109
return null;

src/material-experimental/tsconfig-tests.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"importHelpers": false,
1212
"module": "umd",
1313
"target": "es5",
14-
"types": ["jasmine", "resize-observer-browser"],
14+
"types": ["jasmine"],
1515
"experimentalDecorators": true,
1616
"emitDecoratorMetadata": true,
1717
"paths": {

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"strictBindCallApply": true,
2121
"target": "es2015",
2222
"lib": ["es5", "es2015", "dom"],
23-
"types": ["jasmine", "resize-observer-browser"],
23+
"types": ["jasmine"],
2424
"baseUrl": ".",
2525
"paths": {
2626
"@angular/cdk": ["./src/cdk"],

0 commit comments

Comments
 (0)