@@ -43,7 +43,7 @@ CSSOM.CSSValueExpression.prototype.parse = function() {
4343 STRING : 1 ,
4444 REGEXP : 2
4545 } ,
46- state = STATES . LITERAL ;
46+ state = STATES . LITERAL ,
4747 string_sep = '' ,
4848 expression = '' ,
4949 error = '' ,
@@ -158,10 +158,10 @@ CSSOM.CSSValueExpression.prototype.parse = function() {
158158 * parse regexp in css expression
159159 *
160160 * @return {Object|false }
161- * - idx:
162- * - regExp:
163- * or
164- * false
161+ * - idx:
162+ * - regExp:
163+ * or
164+ * false
165165 */
166166
167167/*
@@ -204,83 +204,83 @@ all legal RegExp
204204=/a/
205205,/a/
206206
207- delete /a/
208- in /a/
207+ delete /a/
208+ in /a/
209209instanceof /a/
210- new /a/
211- typeof /a/
212- void /a/
210+ new /a/
211+ typeof /a/
212+ void /a/
213213
214214*/
215215function parseJSRexExp ( token , idx ) {
216- var before = token . substring ( 0 , idx ) . trimRight ( ) ,
217- legalRegx = [
218- / ^ $ / ,
219- / \( $ / ,
220- / \[ $ / ,
221- / \! $ / ,
222- / \+ $ / ,
223- / \- $ / ,
224- / \* $ / ,
225- / \/ \s + / ,
226- / \% $ / ,
227- / \= $ / ,
228- / \> $ / ,
229- / \< $ / ,
230- / \& $ / ,
231- / \| $ / ,
232- / \^ $ / ,
233- / \~ $ / ,
234- / \? $ / ,
235- / \, $ / ,
236- / d e l e t e $ / ,
237- / i n $ / ,
238- / i n s t a n c e o f $ / ,
239- / n e w $ / ,
240- / t y p e o f $ / ,
241- / v o i d $ / ,
242- ] ;
243-
244- var isLegal = legalRegx . some ( function ( reg ) {
245- return reg . test ( before ) ;
246- } ) ;
247-
248- if ( ! isLegal ) {
249- return false ;
250- } else {
251- var startIdx = idx ,
252- regexp ;
253-
254- while ( true ) {
255- var regEndIdx = token . indexOf ( '/' , startIdx + 1 ) ;
256-
257- if ( regEndIdx === - 1 ) {
258- return false ;
259- } else {
260- regexp = token . substring ( idx + 1 , regEndIdx ) ;
261- var matched = regexp . match ( / \\ + $ / ) ;
262- if ( ! matched || matched [ 0 ] % 2 == 0 ) {
263- regexp = '/' + regexp + '/' ;
264- break ;
265- } else {
266- startIdx = regEndIdx ;
267- }
268- }
269- }
270- }
271-
272- // validate
273- // RegExp boundary(/) must be in the same line
274- var nextNewLineIdx = token . indexOf ( '\n' , idx + 1 ) ;
275- if ( nextNewLineIdx < regEndIdx ) {
276- return false ;
277- }
278-
279-
280- return {
281- idx : regEndIdx ,
282- regExp : regexp
283- } ;
216+ var before = token . substring ( 0 , idx ) . trimRight ( ) ,
217+ legalRegx = [
218+ / ^ $ / ,
219+ / \( $ / ,
220+ / \[ $ / ,
221+ / \! $ / ,
222+ / \+ $ / ,
223+ / \- $ / ,
224+ / \* $ / ,
225+ / \/ \s + / ,
226+ / \% $ / ,
227+ / \= $ / ,
228+ / \> $ / ,
229+ / \< $ / ,
230+ / \& $ / ,
231+ / \| $ / ,
232+ / \^ $ / ,
233+ / \~ $ / ,
234+ / \? $ / ,
235+ / \, $ / ,
236+ / d e l e t e $ / ,
237+ / i n $ / ,
238+ / i n s t a n c e o f $ / ,
239+ / n e w $ / ,
240+ / t y p e o f $ / ,
241+ / v o i d $ / ,
242+ ] ;
243+
244+ var isLegal = legalRegx . some ( function ( reg ) {
245+ return reg . test ( before ) ;
246+ } ) ;
247+
248+ if ( ! isLegal ) {
249+ return false ;
250+ } else {
251+ var startIdx = idx ,
252+ regexp ;
253+
254+ while ( true ) {
255+ var regEndIdx = token . indexOf ( '/' , startIdx + 1 ) ;
256+
257+ if ( regEndIdx === - 1 ) {
258+ return false ;
259+ } else {
260+ regexp = token . substring ( idx + 1 , regEndIdx ) ;
261+ var matched = regexp . match ( / \\ + $ / ) ;
262+ if ( ! matched || matched [ 0 ] % 2 == 0 ) {
263+ regexp = '/' + regexp + '/' ;
264+ break ;
265+ } else {
266+ startIdx = regEndIdx ;
267+ }
268+ }
269+ }
270+ }
271+
272+ // validate
273+ // RegExp boundary(/) must be in the same line
274+ var nextNewLineIdx = token . indexOf ( '\n' , idx + 1 ) ;
275+ if ( nextNewLineIdx < regEndIdx ) {
276+ return false ;
277+ }
278+
279+
280+ return {
281+ idx : regEndIdx ,
282+ regExp : regexp
283+ } ;
284284}
285285
286286
0 commit comments