Debian Codegraph @

mixmark-io-domino/lib/Location.js

raw symbols SCIP
1 "use strict";
2 var URL = require('./URL');
3 var URLUtils = require('./URLUtils');
4
5 module.exports = Location;
6
7 function Location(window, href) {
8 this._window = window;
9 this._href = href;
10 }
11
12 Location.prototype = Object.create(URLUtils.prototype, {
13 constructor: { value: Location },
14
15 // Special behavior when href is set
16 href: {
17 get: function() { return this._href; },
18 set: function(v) { this.assign(v); }
19 },
20
21 assign: { value: function(url) {
22 // Resolve the new url against the current one
23 // XXX:
24 // This is not actually correct. It should be resolved against
25 // the URL of the document of the script. For now, though, I only
26 // support a single window and there is only one base url.
27 // So this is good enough for now.
28 var current = new URL(this._href);
29 var newurl = current.resolve(url);
30
31 // Save the new url
32 this._href = newurl;
33
34 // Start loading the new document!
35 // XXX
36 // This is just something hacked together.
37 // The real algorithm is: http://www.whatwg.org/specs/web-apps/current-work/multipage/history.html#navigate
38 }},
39
40 replace: { value: function(url) {
41 // XXX
42 // Since we aren't tracking history yet, replace is the same as assign
43 this.assign(url);
44 }},
45
46 reload: { value: function() {
47 // XXX:
48 // Actually, the spec is a lot more complicated than this
49 this.assign(this.href);
50 }},
51
52 toString: { value: function() {
53 return this.href;
54 }}
55
56 });