Permalink
Browse files

rename tempThis to this

  • Loading branch information...
1 parent 6eaf3b8 commit d34ebdca12ad282a5a5f9f0c49d2e350c4e329e7 @switer committed Mar 12, 2014
Showing with 7 additions and 7 deletions.
  1. +7 −7 router.js
View
@@ -9,7 +9,7 @@
var _hashHandlers = [];
// Route构造函数
var R = function () {
- var tempThis = this;
+ var that = this;
// binding routes
_bindRoutes = function () {
if ( !this.routes )
@@ -45,7 +45,7 @@
*/
R.start = function () {
if ( !isRouteStart ) {
- var tempThis = this;
+ var that = this;
function hashChange () {
var hash = window.location.hash;
var route = this.trigger ( hash.replace ( routeFn.routeStripper, '' ) ); //router的渲染函数
@@ -54,14 +54,14 @@
//浏览器支持使用hashchange
if( 'onhashchange' in window ) {
window.onhashchange = function () {
- hashChange.call ( tempThis.prototype );
+ hashChange.call ( that.prototype );
}
} else {//浏览器不支持hashchange使用轮询
setInterval(function () {
var hash = window.location.hash;
- if(hash != tempThis.fragment) {
- tempThis.fragment = hash;
- hashChange.call ( tempThis.prototype );
+ if(hash != that.fragment) {
+ that.fragment = hash;
+ hashChange.call ( that.prototype );
}
}, 50);
}
@@ -89,7 +89,7 @@
*/
R.prototype.trigger = function ( fragment ) {
var matched;
- var tempThis = this;
+ var that = this;
routeFn.any ( _handlers, function ( handler ) {
if ( handler.route.test ( fragment ) ) {
//route handler调用前调用的方法

0 comments on commit d34ebdc

Please sign in to comment.