Skip to content

Commit 5aeeb3b

Browse files
committed
hotfix(media): Simplify removeCSSClass method
This commit simplifies the `removeCSSClass` method in the `MediaComponent` by removing the commented code and consolidating the removal of the CSS class from the `body` and `ion-app` elements in a single conditional block. The method now checks for the existence of the `body` and `ion-app` elements before attempting to remove the CSS class, ensuring a more concise and efficient implementation.
1 parent 91a457c commit 5aeeb3b

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/app/shared/media/component/media.component.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -175,15 +175,15 @@ export class MediaComponent implements AfterViewInit, OnDestroy {
175175
* and the native player is no longer needed.
176176
*/
177177
private removeCSSClass() {
178-
// Remove the CSS class from the body element
179-
this.renderer.removeClass(
180-
this.elementRef.nativeElement.ownerDocument.body,
181-
this.globalCSSClass
182-
);
183-
// Remove the CSS class from the ion-app element
184-
this.renderer.removeClass(
185-
this.elementRef.nativeElement.ownerDocument.querySelector('ion-app'),
186-
this.globalCSSClass
187-
);
178+
const bodyElement = this.elementRef.nativeElement.ownerDocument.body;
179+
const ionAppElement =
180+
this.elementRef.nativeElement.ownerDocument.querySelector('ion-app');
181+
182+
if (bodyElement && ionAppElement) {
183+
// Remove the CSS class from the body element
184+
this.renderer.removeClass(bodyElement, this.globalCSSClass);
185+
// Remove the CSS class from the ion-app element
186+
this.renderer.removeClass(ionAppElement, this.globalCSSClass);
187+
}
188188
}
189189
}

0 commit comments

Comments
 (0)