Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Adjusted special 'spacerun span' elements normalization function for …
Browse files Browse the repository at this point in the history
…Edge browser.
  • Loading branch information
f1ames committed Oct 26, 2018
1 parent eca95b1 commit 316f893
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/filters/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,10 @@ function normalizeEndTagsPrecedingSpace( htmlString ) {
// @param {Document} htmlDocument Native `Document` object in which spacing should be normalized.
function normalizeSpacerunSpans( htmlDocument ) {
htmlDocument.querySelectorAll( 'span[style*=spacerun]' ).forEach( el => {
const spacesReplacemanet = Array( el.innerText.length + 1 ).join( '\u00A0 ' ).substr( 0, el.innerText.length );
// Use `el.childNodes[ 0 ].data.length` instead of `el.innerText.length`. For `el.innerText.length` which
// contains spaces mixed with ` `, Edge browser returns incorrect length.
const innerTextLength = el.childNodes[ 0 ].data.length;

el.innerHTML = spacesReplacemanet;
el.innerHTML = Array( innerTextLength + 1 ).join( '\u00A0 ' ).substr( 0, innerTextLength );
} );
}

0 comments on commit 316f893

Please sign in to comment.