diff options
author | Timmy Willison <4timmywil@gmail.com> | 2016-09-12 12:32:02 -0400 |
---|---|---|
committer | Timmy Willison <4timmywil@gmail.com> | 2016-09-15 10:40:27 -0400 |
commit | 3bbcce68d7b8b8a7a2164a0f7a280ae9daf70b5c (patch) | |
tree | a65aefeef8aa62ff092254dcd5b1f2c256dc82ea /src/core/stripAndCollapse.js | |
parent | 2d4f53416e5f74fa98e0c1d66b6f3c285a12f0ce (diff) | |
download | jquery-3bbcce68d7b8b8a7a2164a0f7a280ae9daf70b5c.tar.gz jquery-3bbcce68d7b8b8a7a2164a0f7a280ae9daf70b5c.zip |
Core: rnotwhite -> rhtmlnotwhite and jQuery.trim -> stripAndCollapse
- Renames and changes rnotwhite to focus on HTML whitespace chars
- Change internal use of jQuery.trim to more accurate strip and collapse
- Adds tests to ensure HTML space characters are retained where valid
- Doesn't add tests where the difference is inconsequential and
existing tests are adequate.
Fixes gh-3003
Fixes gh-3072
Close gh-3316
Diffstat (limited to 'src/core/stripAndCollapse.js')
-rw-r--r-- | src/core/stripAndCollapse.js | 12 |
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; +} ); |