Skip to content

Commit

Permalink
full :local-link support
Browse files Browse the repository at this point in the history
  • Loading branch information
chjj committed Mar 9, 2012
1 parent a4aa817 commit df38fcc
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions lib/zest.js
Expand Up @@ -8,7 +8,6 @@
// - Recognize the TR subject selector when parsing.
// - Pass context to scope.
// - Add :column pseudo-classes.
// - Full support for path/domain parts in :local-link.

;(function() {

Expand Down Expand Up @@ -337,9 +336,20 @@ var selectors = {
if (el.nodeName) {
return el.href && el.host === window.location.host;
}
var param = el;
var param = +el + 1;
return function(el) {
return selectors[':local-link'](el);
if (!el.href) return;

var url = window.location + ''
, href = el + '';

url = url.replace(/^\w+:\/\/|^\/+|\/*#?.*?$/g, '');
url = url.split('/').slice(0, param).join('/');

href = href.replace(/^\w+:\/\/|^\/+|\/*#?.*?$/g, '');
href = href.split('/').slice(0, param).join('/');

return url === href;
};
},
':default': function(el) {
Expand Down

0 comments on commit df38fcc

Please sign in to comment.