@@ -9,36 +9,6 @@ module.exports = function(css, options){
9
9
var lineno = 1 ;
10
10
var column = 1 ;
11
11
12
- /**
13
- * Shim-wrapper for trim. Will use native trim if supported, otherwise the trim
14
- * found at https://github.com/kriskowal/es5-shim/blob/master/es5-shim.js
15
- * at commit 32ff9747d5baaa446d5a49d0078ed38fcff93ab0
16
- *
17
- * Modified a bit to not pollute String prototype.
18
- */
19
-
20
- function trim ( str ) {
21
- if ( str === void 0 || str === null ) {
22
- throw new TypeError ( 'trim called on null or undefined' ) ;
23
- }
24
-
25
- var ws = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003' +
26
- '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028' +
27
- '\u2029\uFEFF' ;
28
-
29
- if ( ! String . prototype . trim || ws . trim ( ) ) {
30
- // http://blog.stevenlevithan.com/archives/faster-trim-javascript
31
- // http://perfectionkills.com/whitespace-deviations/
32
- ws = "[" + ws + "]" ;
33
- var trimBeginRegexp = new RegExp ( "^" + ws + ws + "*" ) ;
34
- var trimEndRegexp = new RegExp ( ws + ws + "*$" ) ;
35
-
36
- return String ( str ) . replace ( trimBeginRegexp , "" ) . replace ( trimEndRegexp , "" ) ;
37
- }
38
-
39
- return String ( str ) . trim ( ) ;
40
- }
41
-
42
12
/**
43
13
* Update lineno and column based on `str`.
44
14
*/
@@ -198,7 +168,7 @@ module.exports = function(css, options){
198
168
function selector ( ) {
199
169
var m = match ( / ^ ( [ ^ { ] + ) / ) ;
200
170
if ( ! m ) return ;
201
- return trim ( m [ 0 ] ) . split ( / \s * , \s * / ) ;
171
+ return m [ 0 ] . replace ( / ^ \s + | \s + $ / g , '' ) . split ( / \s * , \s * / ) ;
202
172
}
203
173
204
174
/**
@@ -223,7 +193,7 @@ module.exports = function(css, options){
223
193
var ret = pos ( {
224
194
type : 'declaration' ,
225
195
property : prop ,
226
- value : trim ( val [ 0 ] )
196
+ value : val [ 0 ] . replace ( / ^ \s + | \s + $ / g , '' )
227
197
} ) ;
228
198
229
199
// ;
@@ -320,7 +290,7 @@ module.exports = function(css, options){
320
290
var m = match ( / ^ @ s u p p o r t s * ( [ ^ { ] + ) / ) ;
321
291
322
292
if ( ! m ) return ;
323
- var supports = trim ( m [ 1 ] ) ;
293
+ var supports = m [ 1 ] . replace ( / ^ \s + | \s + $ / g , '' ) ;
324
294
325
295
if ( ! open ( ) ) return error ( "@supports missing '{'" ) ;
326
296
@@ -344,7 +314,7 @@ module.exports = function(css, options){
344
314
var m = match ( / ^ @ m e d i a * ( [ ^ { ] + ) / ) ;
345
315
346
316
if ( ! m ) return ;
347
- var media = trim ( m [ 1 ] ) ;
317
+ var media = m [ 1 ] . replace ( / ^ \s + | \s + $ / g , '' ) ;
348
318
349
319
if ( ! open ( ) ) return error ( "@media missing '{'" ) ;
350
320
@@ -398,8 +368,8 @@ module.exports = function(css, options){
398
368
var m = match ( / ^ @ ( [ - \w ] + ) ? d o c u m e n t * ( [ ^ { ] + ) / ) ;
399
369
if ( ! m ) return ;
400
370
401
- var vendor = trim ( m [ 1 ] || '' ) ;
402
- var doc = trim ( m [ 2 ] ) ;
371
+ var vendor = ( m [ 1 ] || '' ) . replace ( / ^ \s + | \s + $ / g , '' ) ;
372
+ var doc = m [ 2 ] . replace ( / ^ \s + | \s + $ / g , '' ) ;
403
373
404
374
if ( ! open ( ) ) return error ( "@document missing '{'" ) ;
405
375
@@ -448,7 +418,7 @@ module.exports = function(css, options){
448
418
var m = match ( new RegExp ( '^@' + name + ' *([^;\\n]+);' ) ) ;
449
419
if ( ! m ) return ;
450
420
var ret = { type : name } ;
451
- ret [ name ] = trim ( m [ 1 ] ) ;
421
+ ret [ name ] = m [ 1 ] . replace ( / ^ \s + | \s + $ / g , '' ) ;
452
422
return pos ( ret ) ;
453
423
}
454
424
0 commit comments