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

Commit 5bd23fd

Browse files
committed
merge
2 parents d717020 + 861bac1 commit 5bd23fd

File tree

4 files changed

+49
-0
lines changed

4 files changed

+49
-0
lines changed

src/Angular.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,3 +411,4 @@ function angularInit(config){
411411
compile(window.document, config).$init();
412412
}
413413
}
414+

src/Scope.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ function createScope(parent, Class) {
163163
behavior.$root = instance;
164164
behavior.$parent = instance;
165165
}
166+
166167
(parent.$onEval || noop)(instance.$eval);
167168
Class.apply(instance, slice.call(arguments, 2, arguments.length));
168169

src/UrlWatcher.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
2+
// ////////////////////////////
3+
// UrlWatcher
4+
// ////////////////////////////
5+
6+
function UrlWatcher(location) {
7+
this.location = location;
8+
this.delay = 25;
9+
this.setTimeout = function(fn, delay) {
10+
window.setTimeout(fn, delay);
11+
};
12+
this.expectedUrl = location.href;
13+
this.listeners = [];
14+
}
15+
16+
UrlWatcher.prototype = {
17+
watch: function(fn){
18+
this.listeners.push(fn);
19+
},
20+
21+
start: function() {
22+
var self = this;
23+
(function pull () {
24+
if (self.expectedUrl !== self.location.href) {
25+
foreach(self.listeners, function(listener){
26+
listener(self.location.href);
27+
});
28+
self.expectedUrl = self.location.href;
29+
}
30+
self.setTimeout(pull, self.delay);
31+
})();
32+
},
33+
34+
set: function(url) {
35+
var existingURL = this.location.href;
36+
if (!existingURL.match(/#/))
37+
existingURL += '#';
38+
if (existingURL != url)
39+
this.location.href = url;
40+
this.existingURL = url;
41+
},
42+
43+
get: function() {
44+
return this.location.href;
45+
}
46+
};

test/servicesSpec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,5 @@ describe("services", function(){
4545

4646
expect(scope.$location()).toEqual('file:///Users/Shared/misko/work/angular.js/scenario/widgets.html');
4747
});
48+
4849
});

0 commit comments

Comments
 (0)