Skip to content

Commit b5d09b9

Browse files
gibson042timmywil
authored andcommitted
Core: Compress stripAndCollapse
Close gh-3318
1 parent 3bbcce6 commit b5d09b9

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/core/stripAndCollapse.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
define( function() {
1+
define( [
2+
"../var/rnothtmlwhite"
3+
], function( rnothtmlwhite ) {
24
"use strict";
35

46
// Strip and collapse whitespace according to HTML spec
57
// https://html.spec.whatwg.org/multipage/infrastructure.html#strip-and-collapse-whitespace
6-
var rhtmlSpace = /[\x20\t\r\n\f]+/g,
7-
stripAndCollapse = function( value ) {
8-
return ( " " + value + " " ).replace( rhtmlSpace, " " ).slice( 1, -1 );
9-
};
8+
function stripAndCollapse( value ) {
9+
var tokens = value.match( rnothtmlwhite ) || [];
10+
return tokens.join( " " );
11+
}
1012

1113
return stripAndCollapse;
1214
} );

0 commit comments

Comments
 (0)