Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit f6c912c

Browse files
committed
WIP: hack to support different getter/setter APIs
1 parent d0a66ed commit f6c912c

File tree

1 file changed

+49
-15
lines changed

1 file changed

+49
-15
lines changed

test/ng/browserSpecs.js

Lines changed: 49 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,21 +51,55 @@ function MockWindow(options) {
5151
mockWindow.history.state = null;
5252
}
5353
};
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+
}
69103

70104
this.history = {
71105
replaceState: noop,

0 commit comments

Comments
 (0)