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

Commit

Permalink
Other: Remove the complicated innerText.length calculations, required…
Browse files Browse the repository at this point in the history
  • Loading branch information
tomalec committed Apr 20, 2020
1 parent f38afc0 commit 572aaa9
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions src/filters/space.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,7 @@ export function normalizeSpacing( htmlString ) {
*/
export function normalizeSpacerunSpans( htmlDocument ) {
htmlDocument.querySelectorAll( 'span[style*=spacerun]' ).forEach( el => {
// 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 &&
el.childNodes[ 0 ] &&
el.childNodes[ 0 ].data &&
el.childNodes[ 0 ].data.length ) || 0;
const innerTextLength = el.innerText.length || 0;

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

0 comments on commit 572aaa9

Please sign in to comment.