aboutsummaryrefslogtreecommitdiffstats
path: root/src/core/stripAndCollapse.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/stripAndCollapse.js')
-rw-r--r--src/core/stripAndCollapse.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/core/stripAndCollapse.js b/src/core/stripAndCollapse.js
new file mode 100644
index 000000000..797d9f531
--- /dev/null
+++ b/src/core/stripAndCollapse.js
@@ -0,0 +1,12 @@
+define( function() {
+ "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 );
+ };
+
+ return stripAndCollapse;
+} );