Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

dirty hack to enable the `a[href^=#]` selector

Where there are no quotes around the "#" value, Webkit chokes on the
selector. Twitter Bootstrap uses the expression without the quotes.
  • Loading branch information...
commit d56c48bd59440187bd33712d13804304610d39dc 1 parent 16211ae
@mislav mislav authored
Showing with 7 additions and 0 deletions.
  1. +2 −0  src/selector.js
  2. +5 −0 test/selector.html
View
2  src/selector.js
@@ -35,6 +35,8 @@
classTag = 'Zepto' + (+new Date())
function process(sel, fn) {
+ // quote the hash in `a[href^=#]` expression
+ sel = sel.replace(/=#\]/g, '="#"]')
var filter, arg, match = filterRe.exec(sel)
if (match && match[2] in filters) {
var filter = filters[match[2]], arg = match[3]
View
5 test/selector.html
@@ -78,6 +78,11 @@
}).get()
t.assertEqual('child2', results.join(' '))
+ },
+ testEmptyHref: function(t) {
+ var result, el = $('<div><a href="#">one</a><a href="#">two</a></div>')
+ result = el.find('a[href=#]')
+ t.assertEqual('one two', result.map(function(){ return $(this).text() }).get().join(' '))
}
})
})()
Please sign in to comment.
Something went wrong with that request. Please try again.