From 920706b287cb27e45dd09d93cb5a79f0c393e220 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tadas=20Karpavi=C4=8Dius?= Date: Mon, 9 Aug 2021 16:00:42 +0300 Subject: [PATCH] Remove height and maxHeight entirely on destroy() Setting them to "initial" breaks the automatic maxHeight (set by the CSS) pickup. E.g. if the max-height set in the CSS uses relative units (rem, %, vh, vw, etc.), you want to "refresh" the readmore block on resize by destroying it and then initializing it again. That is currently impossible without clearing styles manually like so: ` const $el = readMore.elements[0]; readMore.destroy(readMore.elements[0]); $el.style.height = ''; $el.style.maxHeight = ''; ` --- src/readmore.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/readmore.js b/src/readmore.js index 5f4aad7..8a8d523 100644 --- a/src/readmore.js +++ b/src/readmore.js @@ -374,8 +374,8 @@ class Readmore { delete element.readmore; - element.style.height = 'initial'; - element.style.maxHeight = 'initial'; + element.style.height = ''; + element.style.maxHeight = ''; element.removeAttribute('data-readmore'); element.removeAttribute('aria-expanded');