aboutsummaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorRichard Gibson <richard.gibson@gmail.com>2016-09-15 22:42:34 -0400
committerTimmy Willison <4timmywil@gmail.com>2016-09-19 09:19:48 -0400
commitb5d09b90ca39876d1d9cc29508cfd56e7e3c350e (patch)
tree6086c11939be480dab652682d2d65e8a20b00610 /src/core
parent3bbcce68d7b8b8a7a2164a0f7a280ae9daf70b5c (diff)
downloadjquery-b5d09b90ca39876d1d9cc29508cfd56e7e3c350e.tar.gz
jquery-b5d09b90ca39876d1d9cc29508cfd56e7e3c350e.zip
Core: Compress stripAndCollapse
Close gh-3318
Diffstat (limited to 'src/core')
-rw-r--r--src/core/stripAndCollapse.js12
1 files 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;
} );