Skip to content

Commit b305b22

Browse files
authored
feat(purescript-web#8): Add HTMLHyperlinkElementUtils module (purescript-web#44)
1 parent 2f7d7a1 commit b305b22

File tree

3 files changed

+210
-0
lines changed

3 files changed

+210
-0
lines changed

src/Web/HTML/HTMLAnchorElement.purs

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import Web.DOM.DOMTokenList (DOMTokenList)
99
import Web.Event.EventTarget (EventTarget)
1010
import Web.HTML.HTMLElement (HTMLElement)
1111
import Web.Internal.FFI (unsafeReadProtoTagged)
12+
import Web.HTML.HTMLHyperlinkElementUtils (HTMLHyperlinkElementUtils)
1213

1314
foreign import data HTMLAnchorElement :: Type
1415

@@ -54,6 +55,9 @@ toParentNode = unsafeCoerce
5455
toEventTarget :: HTMLAnchorElement -> EventTarget
5556
toEventTarget = unsafeCoerce
5657

58+
toHTMLHyperlinkElementUtils :: HTMLAnchorElement -> HTMLHyperlinkElementUtils
59+
toHTMLHyperlinkElementUtils = unsafeCoerce
60+
5761
foreign import target :: HTMLAnchorElement -> Effect String
5862
foreign import setTarget :: String -> HTMLAnchorElement -> Effect Unit
5963

+167
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
"use strict";
2+
3+
exports.href = function (u) {
4+
return function () {
5+
return u.href;
6+
};
7+
};
8+
9+
exports.setHref = function (href) {
10+
return function (u) {
11+
return function () {
12+
u.href = href;
13+
};
14+
};
15+
};
16+
17+
// ----------------------------------------------------------------------------
18+
19+
exports.origin = function (u) {
20+
return function () {
21+
return u.origin;
22+
};
23+
};
24+
25+
// ----------------------------------------------------------------------------
26+
27+
exports.protocol = function (u) {
28+
return function () {
29+
return u.protocol;
30+
};
31+
};
32+
33+
exports.setProtocol = function (protocol) {
34+
return function (u) {
35+
return function () {
36+
u.protocol = protocol;
37+
};
38+
};
39+
};
40+
41+
// ----------------------------------------------------------------------------
42+
43+
exports.username = function (u) {
44+
return function () {
45+
return u.username;
46+
};
47+
};
48+
49+
exports.setUsername = function (username) {
50+
return function (u) {
51+
return function () {
52+
u.username = username;
53+
};
54+
};
55+
};
56+
57+
// ----------------------------------------------------------------------------
58+
59+
exports.password = function (u) {
60+
return function () {
61+
return u.password;
62+
};
63+
};
64+
65+
exports.setPassword = function (password) {
66+
return function (u) {
67+
return function () {
68+
u.password = password;
69+
};
70+
};
71+
};
72+
73+
// ----------------------------------------------------------------------------
74+
75+
exports.host = function (u) {
76+
return function () {
77+
return u.host;
78+
};
79+
};
80+
81+
exports.setHost = function (host) {
82+
return function (u) {
83+
return function () {
84+
u.host = host;
85+
};
86+
};
87+
};
88+
89+
// ----------------------------------------------------------------------------
90+
91+
exports.hostname = function (u) {
92+
return function () {
93+
return u.hostname;
94+
};
95+
};
96+
97+
exports.setHostname = function (hostname) {
98+
return function (u) {
99+
return function () {
100+
u.hostname = hostname;
101+
};
102+
};
103+
};
104+
105+
// ----------------------------------------------------------------------------
106+
107+
exports.port = function (u) {
108+
return function () {
109+
return u.port;
110+
};
111+
};
112+
113+
exports.setPort = function (port) {
114+
return function (u) {
115+
return function () {
116+
u.port = port;
117+
};
118+
};
119+
};
120+
121+
// ----------------------------------------------------------------------------
122+
123+
exports.pathname = function (u) {
124+
return function () {
125+
return u.pathname;
126+
};
127+
};
128+
129+
exports.setPathname = function (pathname) {
130+
return function (u) {
131+
return function () {
132+
u.pathname = pathname;
133+
};
134+
};
135+
};
136+
137+
// ----------------------------------------------------------------------------
138+
139+
exports.search = function (u) {
140+
return function () {
141+
return u.search;
142+
};
143+
};
144+
145+
exports.setSearch = function (search) {
146+
return function (u) {
147+
return function () {
148+
u.search = search;
149+
};
150+
};
151+
};
152+
153+
// ----------------------------------------------------------------------------
154+
155+
exports.hash = function (u) {
156+
return function () {
157+
return u.hash;
158+
};
159+
};
160+
161+
exports.setHash = function (hash) {
162+
return function (u) {
163+
return function () {
164+
u.hash = hash;
165+
};
166+
};
167+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
-- https://html.spec.whatwg.org/multipage/links.html#htmlhyperlinkelementutils
2+
module Web.HTML.HTMLHyperlinkElementUtils where
3+
4+
import Effect (Effect)
5+
import Prelude (Unit)
6+
7+
foreign import data HTMLHyperlinkElementUtils :: Type
8+
9+
foreign import href :: HTMLHyperlinkElementUtils -> Effect String
10+
foreign import setHref :: String -> HTMLHyperlinkElementUtils -> Effect Unit
11+
12+
foreign import origin :: HTMLHyperlinkElementUtils -> Effect String
13+
14+
foreign import protocol :: HTMLHyperlinkElementUtils -> Effect String
15+
foreign import setProtocol :: String -> HTMLHyperlinkElementUtils -> Effect Unit
16+
17+
foreign import username :: HTMLHyperlinkElementUtils -> Effect String
18+
foreign import setUsername :: String -> HTMLHyperlinkElementUtils -> Effect Unit
19+
20+
foreign import password :: HTMLHyperlinkElementUtils -> Effect String
21+
foreign import setPassword :: String -> HTMLHyperlinkElementUtils -> Effect Unit
22+
23+
foreign import host :: HTMLHyperlinkElementUtils -> Effect String
24+
foreign import setHost :: String -> HTMLHyperlinkElementUtils -> Effect Unit
25+
26+
foreign import hostname :: HTMLHyperlinkElementUtils -> Effect String
27+
foreign import setHostname :: String -> HTMLHyperlinkElementUtils -> Effect Unit
28+
29+
foreign import port :: HTMLHyperlinkElementUtils -> Effect String
30+
foreign import setPort :: String -> HTMLHyperlinkElementUtils -> Effect Unit
31+
32+
foreign import pathname :: HTMLHyperlinkElementUtils -> Effect String
33+
foreign import setPathname :: String -> HTMLHyperlinkElementUtils -> Effect Unit
34+
35+
foreign import search :: HTMLHyperlinkElementUtils -> Effect String
36+
foreign import setSearch :: String -> HTMLHyperlinkElementUtils -> Effect Unit
37+
38+
foreign import hash :: HTMLHyperlinkElementUtils -> Effect String
39+
foreign import setHash :: String -> HTMLHyperlinkElementUtils -> Effect Unit

0 commit comments

Comments
 (0)