@@ -8,6 +8,7 @@ const singleQuote = '\''.charCodeAt(0);
88const doubleQuote = '"' . charCodeAt ( 0 ) ;
99const backslash = '\\' . charCodeAt ( 0 ) ;
1010const slash = '/' . charCodeAt ( 0 ) ;
11+ const period = '.' . charCodeAt ( 0 ) ;
1112const comma = ',' . charCodeAt ( 0 ) ;
1213const colon = ':' . charCodeAt ( 0 ) ;
1314const asterisk = '*' . charCodeAt ( 0 ) ;
@@ -20,6 +21,10 @@ const feed = '\f'.charCodeAt(0);
2021const tab = '\t' . charCodeAt ( 0 ) ;
2122const cr = '\r' . charCodeAt ( 0 ) ;
2223const at = '@' . charCodeAt ( 0 ) ;
24+ const lowerE = 'e' . charCodeAt ( 0 ) ;
25+ const upperE = 'E' . charCodeAt ( 0 ) ;
26+ const digit0 = '0' . charCodeAt ( 0 ) ;
27+ const digit9 = '9' . charCodeAt ( 0 ) ;
2328const atEnd = / [ \n \t \r \{ \( \) ' " \\ ; , / ] / g;
2429const wordEnd = / [ \n \t \r \( \) \{ \} \* : ; @ ! & ' " \+ \| ~ > , \[ \] \\ ] | \/ (? = \* ) / g;
2530const wordEndNum = / [ \n \t \r \( \) \{ \} \* : ; @ ! & ' " \- \+ \| ~ > , \[ \] \\ ] | \/ / g;
@@ -299,7 +304,7 @@ module.exports = function tokenize (input, options) {
299304
300305 // we're dealing with a word that starts with a number
301306 // those get treated differently
302- if ( code >= 48 && code <= 57 ) {
307+ if ( code >= digit0 && code <= digit9 ) {
303308 regex = wordEndNum ;
304309 }
305310
@@ -313,6 +318,29 @@ module.exports = function tokenize (input, options) {
313318 next = regex . lastIndex - 2 ;
314319 }
315320
321+ // Exponential number notation with minus or plus: 1e-10, 1e+10
322+ if ( regex === wordEndNum || code === period ) {
323+ let ncode1 = css . charCodeAt ( next ) ,
324+ ncode2 = css . charCodeAt ( next + 1 ) ,
325+ ncode3 = css . charCodeAt ( next + 2 ) ;
326+
327+ if (
328+ ( ncode1 === lowerE || ncode1 === upperE ) &&
329+ ( ncode2 === minus || ncode2 === plus ) &&
330+ ( ncode3 >= digit0 && ncode3 <= digit9 )
331+ ) {
332+ wordEndNum . lastIndex = next + 2 ;
333+ wordEndNum . test ( css ) ;
334+
335+ if ( wordEndNum . lastIndex === 0 ) {
336+ next = css . length - 1 ;
337+ }
338+ else {
339+ next = wordEndNum . lastIndex - 2 ;
340+ }
341+ }
342+ }
343+
316344 tokens . push ( [ 'word' , css . slice ( pos , next + 1 ) ,
317345 line , pos - offset ,
318346 line , next - offset ,
0 commit comments