Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

small regexp fixes

  • Loading branch information...
commit 7fe0cf0f85f72338cb170de863b18ccf19a2114c 1 parent 3c9cfa4
@amccollum authored
Showing with 6 additions and 3 deletions.
  1. +2 −1  lib/sel.js
  2. +2 −1  src/sel/parser.coffee
  3. +2 −1  src/sel/sel.coffee
View
3  lib/sel.js
@@ -145,7 +145,7 @@
};
/* parser.coffee
*/
- attrPattern = /\[\s*([-\w]+)\s*(?:([~|^$*!]?=)\s*(?:([-\w]+)|['"]([^'"]*)['"]\s*(i))\s*)?\]/g;
+ attrPattern = /\[\s*([-\w]+)\s*(?:([~|^$*!]?=)\s*(?:([-\w]+)|['"]([^'"]*)['"])\s*(i)?\s*)?\]/g;
pseudoPattern = /::?([-\w]+)(?:\((\([^()]+\)|[^()]+)\))?/g;
combinatorPattern = /^\s*([,+~]|\/([-\w]+)\/)/;
selectorPattern = RegExp("^(?:\\s*(>))?\\s*(?:(\\*|\\w+))?(?:\\#([-\\w]+))?(?:\\.([-\\.\\w]+))?((?:" + attrPattern.source + ")*)((?:" + pseudoPattern.source + ")*)(!)?");
@@ -160,6 +160,7 @@
};
parse = function(selector) {
var e, last, result;
+ selector = selector.trim();
if (selector in parse.cache) return parse.cache[selector];
result = last = e = parseSimple(selector);
if (e.compound) e.children = [];
View
3  src/sel/parser.coffee
@@ -3,7 +3,7 @@
attrPattern = ///
\[
\s* ([-\w]+) \s*
- (?: ([~|^$*!]?=) \s* (?: ([-\w]+) | ['"]([^'"]*)['"] \s* (i)) \s* )?
+ (?: ([~|^$*!]?=) \s* (?: ([-\w]+) | ['"]([^'"]*)['"]) \s* (i)? \s* )?
\]
///g
@@ -45,6 +45,7 @@
}
parse = (selector) ->
+ selector = selector.trim()
if selector of parse.cache
return parse.cache[selector]
View
3  src/sel/sel.coffee
@@ -120,7 +120,7 @@
attrPattern = ///
\[
\s* ([-\w]+) \s*
- (?: ([~|^$*!]?=) \s* (?: ([-\w]+) | ['"]([^'"]*)['"] \s* (i)) \s* )?
+ (?: ([~|^$*!]?=) \s* (?: ([-\w]+) | ['"]([^'"]*)['"]) \s* (i)? \s* )?
\]
///g
@@ -162,6 +162,7 @@
}
parse = (selector) ->
+ selector = selector.trim()
if selector of parse.cache
return parse.cache[selector]
Please sign in to comment.
Something went wrong with that request. Please try again.