diff --git a/src/shave.js b/src/shave.js index 5435c035..cfc55f57 100644 --- a/src/shave.js +++ b/src/shave.js @@ -57,10 +57,13 @@ export default function shave (target, maxHeight, opts = {}) { el.insertAdjacentHTML('beforeend', charHtml) const diff = spaces ? ` ${words.slice(max).join(' ')}` : words.slice(max) - el.insertAdjacentHTML( - 'beforeend', - ``, - ) + // https://stackoverflow.com/questions/476821/is-a-dom-text-node-guaranteed-to-not-be-interpreted-as-html + const shavedText = document.createTextNode(diff) + const elWithShavedText = document.createElement('span') + elWithShavedText.classList.add(classname) + elWithShavedText.style.display = 'none' + elWithShavedText.appendChild(shavedText) + el.insertAdjacentElement('beforeend', elWithShavedText) styles.height = heightStyle styles.maxHeight = maxHeightStyle