Skip to content

Commit

Permalink
fix(aria-describer): server-side rendering error during cleanup (#8903)
Browse files Browse the repository at this point in the history
Fixes a potential server-side rendering error when the `AriaDescriber` is being cleaned up.

Fixes #8901.
  • Loading branch information
crisbeto authored and andrewseguin committed Dec 13, 2017
1 parent a4c042b commit 8a3b19e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/cdk/a11y/aria-describer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ export class AriaDescriber {
/** Creates the global container for all aria-describedby messages. */
private _createMessagesContainer() {
messagesContainer = this._document.createElement('div');

messagesContainer.setAttribute('id', MESSAGES_CONTAINER_ID);
messagesContainer.setAttribute('aria-hidden', 'true');
messagesContainer.style.display = 'none';
Expand All @@ -147,8 +146,10 @@ export class AriaDescriber {

/** Deletes the global messages container. */
private _deleteMessagesContainer() {
this._document.body.removeChild(messagesContainer!);
messagesContainer = null;
if (messagesContainer && messagesContainer.parentNode) {
messagesContainer.parentNode.removeChild(messagesContainer);
messagesContainer = null;
}
}

/** Removes all cdk-describedby messages that are hosted through the element. */
Expand Down

0 comments on commit 8a3b19e

Please sign in to comment.