From e40744c9ffd3a9f847089093bb07419e4e0aea3d Mon Sep 17 00:00:00 2001 From: Cory LaViska Date: Mon, 8 Mar 2021 09:06:35 -0500 Subject: [PATCH] add guard --- src/components/responsive-embed/responsive-embed.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/responsive-embed/responsive-embed.ts b/src/components/responsive-embed/responsive-embed.ts index 9cadbd92b..d728c1d5a 100644 --- a/src/components/responsive-embed/responsive-embed.ts +++ b/src/components/responsive-embed/responsive-embed.ts @@ -22,11 +22,13 @@ export class SlResponsiveEmbed extends LitElement { @watch('aspectRatio') updateAspectRatio() { - const split = this.aspectRatio.split(':'); - const x = parseInt(split[0]); - const y = parseInt(split[1]); + if (this.base) { + const split = this.aspectRatio.split(':'); + const x = parseInt(split[0]); + const y = parseInt(split[1]); - this.base.style.paddingBottom = x && y ? `${(y / x) * 100}%` : ''; + this.base.style.paddingBottom = x && y ? `${(y / x) * 100}%` : ''; + } } render() {