@@ -51,21 +51,55 @@ function MockWindow(options) {
51
51
mockWindow . history . state = null ;
52
52
}
53
53
} ;
54
-
55
- this . location . __defineGetter__ ( 'href' , function getHref ( ) {
56
- return locationHref ;
57
- } ) ;
58
- this . location . __defineSetter__ ( 'href' , function setHref ( value ) {
59
- locationHref = value ;
60
- mockWindow . history . state = null ;
61
- historyEntriesLength ++ ;
62
- } ) ;
63
- this . location . __defineGetter__ ( 'hash' , function getHash ( ) {
64
- return getHash ( locationHref ) ;
65
- } ) ;
66
- this . location . __defineSetter__ ( 'hash' , function setHash ( value ) {
67
- locationHref = stripHash ( locationHref ) + '#' + value ;
68
- } ) ;
54
+ dump ( msie ) ;
55
+ if ( ! ( msie < 9 ) ) {
56
+ eval ( [
57
+ "this.location = {" ,
58
+ "get href() {" ,
59
+ "return locationHref;" ,
60
+ "}," ,
61
+ "set href(value) {" ,
62
+ "locationHref = value;" ,
63
+ "mockWindow.history.state = null;" ,
64
+ "historyEntriesLength++;" ,
65
+ "}," ,
66
+ "get hash() {" ,
67
+ "return getHash(locationHref);" ,
68
+ "}," ,
69
+ "set hash(value) {" ,
70
+ "locationHref = stripHash(locationHref) + '#' + value;" ,
71
+ "}," ,
72
+ "replace: function(url) {" ,
73
+ "locationHref = url;" ,
74
+ "mockWindow.history.state = null;" ,
75
+ "}" ,
76
+ "};"
77
+ ] . join ( '\n' ) ) ;
78
+ }
79
+ else {
80
+ eval ( [
81
+ "this.location={" ,
82
+ "replace: function(url) {" ,
83
+ "locationHref = url;" ,
84
+ "mockWindow.history.state = null;" ,
85
+ "}" ,
86
+ "};" ,
87
+ "this.location.__defineGetter__('href', function getHref() {" ,
88
+ "return locationHref;" ,
89
+ "});" ,
90
+ "this.location.__defineSetter__('href', function setHref(value) {" ,
91
+ "locationHref = value;" ,
92
+ "mockWindow.history.state = null;" ,
93
+ "historyEntriesLength++;" ,
94
+ "});" ,
95
+ "this.location.__defineGetter__('hash', function getHash() {" ,
96
+ "return getHash(locationHref);" ,
97
+ "});" ,
98
+ "this.location.__defineSetter__('hash', function setHash(value) {" ,
99
+ "locationHref = stripHash(locationHref) + '#' + value;" ,
100
+ "});"
101
+ ] . join ( '\n' ) ) ;
102
+ }
69
103
70
104
this . history = {
71
105
replaceState : noop ,
0 commit comments