Skip to content

Patch fixes for latest sync #20401

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/material-experimental/mdc-form-field/form-field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,9 @@ export class MatFormField implements AfterViewInit, OnDestroy, AfterContentCheck
if (this._control) {
let ids: string[] = [];

if (this._control.userAriaDescribedBy) {
// TODO(wagnermaciel): Remove the type check when we find the root cause of this bug.
if (this._control.userAriaDescribedBy &&
typeof this._control.userAriaDescribedBy === 'string') {
ids.push(...this._control.userAriaDescribedBy.split(' '));
}

Expand Down
4 changes: 3 additions & 1 deletion src/material/form-field/form-field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,9 @@ export class MatFormField extends _MatFormFieldMixinBase
if (this._control) {
let ids: string[] = [];

if (this._control.userAriaDescribedBy) {
// TODO(wagnermaciel): Remove the type check when we find the root cause of this bug.
if (this._control.userAriaDescribedBy &&
typeof this._control.userAriaDescribedBy === 'string') {
ids.push(...this._control.userAriaDescribedBy.split(' '));
}

Expand Down
29 changes: 17 additions & 12 deletions src/material/icon/icon-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ export class MatIconRegistry implements OnDestroy {
options?: IconOptions): this {
const cleanLiteral = this._sanitizer.sanitize(SecurityContext.HTML, literal);

if (!cleanLiteral && (typeof ngDevMode === 'undefined' || ngDevMode)) {
// TODO: add an ngDevMode check
if (!cleanLiteral) {
throw getMatIconFailedToSanitizeLiteralError(literal);
}

Expand Down Expand Up @@ -217,7 +218,7 @@ export class MatIconRegistry implements OnDestroy {
options?: IconOptions): this {
const cleanLiteral = this._sanitizer.sanitize(SecurityContext.HTML, literal);

if (!cleanLiteral && (typeof ngDevMode === 'undefined' || ngDevMode)) {
if (!cleanLiteral) {
throw getMatIconFailedToSanitizeLiteralError(literal);
}

Expand Down Expand Up @@ -381,11 +382,12 @@ export class MatIconRegistry implements OnDestroy {
return forkJoin(iconSetFetchRequests).pipe(map(() => {
const foundIcon = this._extractIconWithNameFromAnySet(name, iconSetConfigs);

if (!foundIcon && (typeof ngDevMode === 'undefined' || ngDevMode)) {
// TODO: add an ngDevMode check
if (!foundIcon) {
throw getMatIconNameNotFoundError(name);
}

return foundIcon!;
return foundIcon;
}));
}

Expand Down Expand Up @@ -491,7 +493,8 @@ export class MatIconRegistry implements OnDestroy {
div.innerHTML = str;
const svg = div.querySelector('svg') as SVGElement;

if (!svg && (typeof ngDevMode === 'undefined' || ngDevMode)) {
// TODO: add an ngDevMode check
if (!svg) {
throw Error('<svg> tag not found');
}

Expand Down Expand Up @@ -552,31 +555,33 @@ export class MatIconRegistry implements OnDestroy {
throw getMatIconNoHttpProviderError();
}

if (safeUrl == null && (typeof ngDevMode === 'undefined' || ngDevMode)) {
// TODO: add an ngDevMode check
if (safeUrl == null) {
throw Error(`Cannot fetch icon from URL "${safeUrl}".`);
}

const url = this._sanitizer.sanitize(SecurityContext.RESOURCE_URL, safeUrl);

if (!url && (typeof ngDevMode === 'undefined' || ngDevMode)) {
throw getMatIconFailedToSanitizeUrlError(safeUrl!);
// TODO: add an ngDevMode check
if (!url) {
throw getMatIconFailedToSanitizeUrlError(safeUrl);
}

// Store in-progress fetches to avoid sending a duplicate request for a URL when there is
// already a request in progress for that URL. It's necessary to call share() on the
// Observable returned by http.get() so that multiple subscribers don't cause multiple XHRs.
const inProgressFetch = this._inProgressUrlFetches.get(url!);
const inProgressFetch = this._inProgressUrlFetches.get(url);

if (inProgressFetch) {
return inProgressFetch;
}

const req = this._httpClient.get(url!, {responseType: 'text', withCredentials}).pipe(
finalize(() => this._inProgressUrlFetches.delete(url!)),
const req = this._httpClient.get(url, {responseType: 'text', withCredentials}).pipe(
finalize(() => this._inProgressUrlFetches.delete(url)),
share(),
);

this._inProgressUrlFetches.set(url!, req);
this._inProgressUrlFetches.set(url, req);
return req;
}

Expand Down
6 changes: 1 addition & 5 deletions src/material/icon/icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,7 @@ export class MatIcon extends _MatIconMixinBase implements OnChanges, OnInit, Aft
switch (parts.length) {
case 1: return ['', parts[0]]; // Use default namespace.
case 2: return <[string, string]>parts;
default:
if (typeof ngDevMode === 'undefined' || ngDevMode) {
throw Error(`Invalid icon name: "${iconName}"`);
}
return ['', ''];
default: throw Error(`Invalid icon name: "${iconName}"`); // TODO: add an ngDevMode check
}
}

Expand Down