Permalink
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...
mislav committed Oct 6, 2012
1 parent 16211ae commit d56c48bd59440187bd33712d13804304610d39dc
Showing with 7 additions and 0 deletions.
  1. +2 −0 src/selector.js
  2. +5 −0 test/selector.html
View
@@ -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
@@ -78,6 +78,11 @@ <h1>Zepto selector tests</h1>
}).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(' '))
}
})
})()

0 comments on commit d56c48b

Please sign in to comment.