Skip to content

Commit

Permalink
Core: Compress stripAndCollapse
Browse files Browse the repository at this point in the history
Close gh-3318
  • Loading branch information
gibson042 authored and timmywil committed Sep 19, 2016
1 parent 3bbcce6 commit b5d09b9
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions 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;
} );

0 comments on commit b5d09b9

Please sign in to comment.