Commit 20e08572 authored by Jacob Thornton's avatar Jacob Thornton

cache $(href) lookup

parent 706ee46b
...@@ -53,9 +53,10 @@ ...@@ -53,9 +53,10 @@
.find(this.selector) .find(this.selector)
.map(function () { .map(function () {
var href = $(this).attr('href') var href = $(this).attr('href')
return /^#\w/.test(href) , $href = /^#\w/.test(href) && $(href)
&& $(href).length return $href
&& [[ $(href).position().top, href ]] && href.length
&& [[ $href.position().top, href ]]
}) })
.sort(function (a, b) { return a[0] - b[0] }) .sort(function (a, b) { return a[0] - b[0] })
.each(function () { .each(function () {
......
...@@ -53,9 +53,10 @@ ...@@ -53,9 +53,10 @@
.find(this.selector) .find(this.selector)
.map(function () { .map(function () {
var href = $(this).attr('href') var href = $(this).attr('href')
return /^#\w/.test(href) , $href = /^#\w/.test(href) && $(href)
&& $(href).length return $href
&& [[ $(href).position().top, href ]] && href.length
&& [[ $href.position().top, href ]]
}) })
.sort(function (a, b) { return a[0] - b[0] }) .sort(function (a, b) { return a[0] - b[0] })
.each(function () { .each(function () {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment