From a227d6124a5ba1cf3d65379fb85aaec8ee9ce35f Mon Sep 17 00:00:00 2001 From: Nate Weaver Date: Fri, 20 Nov 2020 11:26:15 -0600 Subject: [PATCH] Add vh/vw to the relative unit check; checking for digits isn't needed --- Shared/Article Rendering/main.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Shared/Article Rendering/main.js b/Shared/Article Rendering/main.js index db27502e6..e440ddb81 100644 --- a/Shared/Article Rendering/main.js +++ b/Shared/Article Rendering/main.js @@ -25,7 +25,7 @@ function stripStyles() { document.getElementsByTagName("body")[0].querySelectorAll("[style]").forEach(element => stripStylesFromElement(element, ["color", "background", "font", "max-width", "max-height", "position"])); } -// Constrain the height of iframes whose heights are a percent of the document body to be at most +// Constrain the height of iframes whose heights are defined relative to the document body to be at most // 50% of the viewport width. function constrainBodyRelativeIframes() { let iframes = document.getElementsByTagName("iframe"); @@ -34,7 +34,7 @@ function constrainBodyRelativeIframes() { if (iframe.offsetParent === document.body) { let heightAttribute = iframe.style.height; - if (/^\d+%$/.test(heightAttribute)) { + if (/%|vw|vh$/.test(heightAttribute)) { iframe.classList.add("nnw-constrained"); } }