Skip to content

Commit

Permalink
fix(material-experimental/mdc-progress-bar): check observer function (#…
Browse files Browse the repository at this point in the history
…21986)

* fix(material-experimental/mdc-progress-bar): check observer function

* fix(material-experimental/mdc-progress-bar): use typeof

(cherry picked from commit cfd3bc8)
  • Loading branch information
andrewseguin committed Feb 23, 2021
1 parent c0149eb commit 6024811
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/material-experimental/mdc-progress-bar/progress-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,14 @@ export class MatProgressBar extends _MatProgressBarMixinBase implements AfterVie

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

// Internal client users found production errors where `observe` was not a function
// on the constructed `observer`. This should not happen, but adding this check for this
// edge case.
if (typeof observer.observe === 'function') {
observer.observe(this._rootElement);
return observer;
}
}

return null;
Expand Down

0 comments on commit 6024811

Please sign in to comment.