From b5d09b90ca39876d1d9cc29508cfd56e7e3c350e Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Thu, 15 Sep 2016 22:42:34 -0400 Subject: [PATCH] Core: Compress stripAndCollapse Close gh-3318 --- src/core/stripAndCollapse.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/core/stripAndCollapse.js b/src/core/stripAndCollapse.js index 797d9f531..ccad6602e 100644 --- a/src/core/stripAndCollapse.js +++ b/src/core/stripAndCollapse.js @@ -1,12 +1,14 @@ -define( function() { +define( [ + "../var/rnothtmlwhite" +], function( rnothtmlwhite ) { "use strict"; // Strip and collapse whitespace according to HTML spec // https://html.spec.whatwg.org/multipage/infrastructure.html#strip-and-collapse-whitespace - var rhtmlSpace = /[\x20\t\r\n\f]+/g, - stripAndCollapse = function( value ) { - return ( " " + value + " " ).replace( rhtmlSpace, " " ).slice( 1, -1 ); - }; + function stripAndCollapse( value ) { + var tokens = value.match( rnothtmlwhite ) || []; + return tokens.join( " " ); + } return stripAndCollapse; } );