Skip to content

Commit e7e653e

Browse files
committed
Merge pull request #2 from rafalages/master
minimal code improvements
2 parents a73f8d0 + 16fa779 commit e7e653e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

jsRoute.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var route = {
55

66
routes: [],
77
funcs: [],
8-
actualURL: '',
8+
currentHash: '',
99
interval: null,
1010

1111
add: function(route, func){
@@ -20,14 +20,14 @@ var route = {
2020
},
2121

2222
_check: function() {
23-
if( this.actualURL != document.location.href ) {
24-
this.actualURL = document.location.href;
23+
if( document.location.hash && this.currentHash != document.location.hash) {
24+
this.currentHash = document.location.hash.slice(1);
2525
this._update();
2626
}
2727
},
2828

2929
_findAndExecute: function(route){
30-
for(var i=0; i< this.routes.length; i++){
30+
for( var i = 0, l = this.routes.length; i < l; i++ ){
3131
var re = new RegExp(this.routes[i]);
3232
var match = route.match(re);
3333

@@ -40,7 +40,7 @@ var route = {
4040
},
4141

4242
_update: function(){
43-
var hash = location.hash.slice(1);
43+
var hash = this.currentHash;
4444

4545
this._findAndExecute(hash);
4646
},

0 commit comments

Comments
 (0)