Skip to content
This repository was archived by the owner on Oct 4, 2020. It is now read-only.

Commit 0e90b7c

Browse files
committed
Merge pull request #36 from jonsterling/issue-35
DOM.HTML.Location: add setters; assign, replace, reload (#35)
2 parents 49bafde + 3d8fb83 commit 0e90b7c

File tree

2 files changed

+141
-1
lines changed

2 files changed

+141
-1
lines changed

src/DOM/HTML/Location.js

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,50 +9,144 @@ exports.hash = function (location) {
99
};
1010
};
1111

12+
exports.setHash = function (hash) {
13+
return function (location) {
14+
return function () {
15+
location.hash = hash;
16+
};
17+
};
18+
};
19+
1220
exports.host = function (location) {
1321
return function () {
1422
return location.host;
1523
};
1624
};
1725

26+
exports.setHost = function (host) {
27+
return function (location) {
28+
return function () {
29+
location.host = host;
30+
};
31+
};
32+
};
33+
1834
exports.hostname = function (location) {
1935
return function () {
2036
return location.hostname;
2137
};
2238
};
2339

40+
exports.setHostname = function (hostname) {
41+
return function (location) {
42+
return function () {
43+
location.hostname = hostname;
44+
};
45+
};
46+
};
47+
2448
exports.href = function (location) {
2549
return function () {
2650
return location.href;
2751
};
2852
};
2953

54+
exports.setHref = function (href) {
55+
return function (location) {
56+
return function () {
57+
location.href = href;
58+
};
59+
};
60+
};
61+
3062
exports.origin = function (location) {
3163
return function () {
3264
return location.origin;
3365
};
3466
};
3567

68+
exports.setOrigin = function (origin) {
69+
return function (location) {
70+
return function () {
71+
location.origin = origin;
72+
};
73+
};
74+
};
75+
3676
exports.pathname = function (location) {
3777
return function () {
3878
return location.pathname;
3979
};
4080
};
4181

82+
exports.setPathname = function (pathname) {
83+
return function (location) {
84+
return function () {
85+
location.pathname = pathname;
86+
};
87+
};
88+
};
89+
4290
exports.port = function (location) {
4391
return function () {
4492
return location.port;
4593
};
4694
};
4795

96+
exports.setPort = function (port) {
97+
return function (location) {
98+
return function () {
99+
location.port = port;
100+
};
101+
};
102+
};
103+
48104
exports.protocol = function (location) {
49105
return function () {
50106
return location.protocol;
51107
};
52108
};
53109

110+
exports.setProtocol = function (protocol) {
111+
return function (location) {
112+
return function () {
113+
location.protocol = protocol;
114+
};
115+
};
116+
};
117+
54118
exports.search = function (location) {
55119
return function () {
56120
return location.search;
57121
};
58122
};
123+
124+
exports.setSearch = function (search) {
125+
return function (location) {
126+
return function () {
127+
location.search = search;
128+
};
129+
};
130+
};
131+
132+
exports.assign = function (url) {
133+
return function (location) {
134+
return function () {
135+
location.assign(url);
136+
};
137+
};
138+
};
139+
140+
exports.replace = function (url) {
141+
return function (location) {
142+
return function () {
143+
location.replace(url);
144+
};
145+
};
146+
};
147+
148+
exports.reload = function (location) {
149+
return function() {
150+
location.reload();
151+
};
152+
};

src/DOM/HTML/Location.purs

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,62 @@
1-
module DOM.HTML.Location where
1+
module DOM.HTML.Location
2+
( hash
3+
, setHash
4+
, host
5+
, setHost
6+
, hostname
7+
, setHostname
8+
, href
9+
, setHref
10+
, origin
11+
, setOrigin
12+
, pathname
13+
, setPathname
14+
, port
15+
, setPort
16+
, protocol
17+
, setProtocol
18+
, search
19+
, setSearch
20+
21+
, assign
22+
, replace
23+
, reload
24+
) where
225

326
import Control.Monad.Eff (Eff())
427

28+
import Prelude
29+
530
import DOM
631
import DOM.HTML.Types
732

833
foreign import hash :: forall eff. Location -> Eff (dom :: DOM | eff) String
34+
foreign import setHash :: forall eff. String -> Location -> Eff (dom :: DOM | eff) Unit
35+
936
foreign import host :: forall eff. Location -> Eff (dom :: DOM | eff) String
37+
foreign import setHost :: forall eff. String -> Location -> Eff (dom :: DOM | eff) Unit
38+
1039
foreign import hostname :: forall eff. Location -> Eff (dom :: DOM | eff) String
40+
foreign import setHostname :: forall eff. String -> Location -> Eff (dom :: DOM | eff) Unit
41+
1142
foreign import href :: forall eff. Location -> Eff (dom :: DOM | eff) String
43+
foreign import setHref :: forall eff. String -> Location -> Eff (dom :: DOM | eff) String
44+
1245
foreign import origin :: forall eff. Location -> Eff (dom :: DOM | eff) String
46+
foreign import setOrigin :: forall eff. String -> Location -> Eff (dom :: DOM | eff) Unit
47+
1348
foreign import pathname :: forall eff. Location -> Eff (dom :: DOM | eff) String
49+
foreign import setPathname :: forall eff. String -> Location -> Eff (dom :: DOM | eff) Unit
50+
1451
foreign import port :: forall eff. Location -> Eff (dom :: DOM | eff) String
52+
foreign import setPort :: forall eff. String -> Location -> Eff (dom :: DOM | eff) Unit
53+
1554
foreign import protocol :: forall eff. Location -> Eff (dom :: DOM | eff) String
55+
foreign import setProtocol :: forall eff. String -> Location -> Eff (dom :: DOM | eff) Unit
56+
1657
foreign import search :: forall eff. Location -> Eff (dom :: DOM | eff) String
58+
foreign import setSearch :: forall eff. String -> Location -> Eff (dom :: DOM | eff) Unit
59+
60+
foreign import assign :: forall eff. String -> Location -> Eff (dom :: DOM | eff) Unit
61+
foreign import replace :: forall eff. String -> Location -> Eff (dom :: DOM | eff) Unit
62+
foreign import reload :: forall eff. Location -> Eff (dom :: DOM | eff) Unit

0 commit comments

Comments
 (0)