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

Commit de2b148

Browse files
authored
Merge pull request #144 from chexxor/add-htmlhyperlinkelementutils
Add HTMLHyperlinkElementUtils.
2 parents 13e7a35 + 9d9cfd9 commit de2b148

File tree

3 files changed

+216
-0
lines changed

3 files changed

+216
-0
lines changed
Lines changed: 167 additions & 0 deletions
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+
};
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
-- The `URLUtils` interface, referenced in https://www.w3.org/TR/html50/infrastructure.html#urlutils
2+
-- now documented at https://html.spec.whatwg.org/multipage/links.html#htmlhyperlinkelementutils
3+
module DOM.HTML.HTMLHyperlinkElementUtils where
4+
5+
import Prelude (Unit)
6+
7+
import Control.Monad.Eff (Eff)
8+
9+
import DOM (DOM)
10+
import DOM.HTML.Types (HTMLHyperlinkElementUtils)
11+
12+
foreign import href :: forall eff. HTMLHyperlinkElementUtils -> Eff (dom :: DOM | eff) String
13+
foreign import setHref :: forall eff. String -> HTMLHyperlinkElementUtils -> Eff (dom :: DOM | eff) Unit
14+
15+
foreign import origin :: forall eff. HTMLHyperlinkElementUtils -> Eff (dom :: DOM | eff) String
16+
17+
foreign import protocol :: forall eff. HTMLHyperlinkElementUtils -> Eff (dom :: DOM | eff) String
18+
foreign import setProtocol :: forall eff. String -> HTMLHyperlinkElementUtils -> Eff (dom :: DOM | eff) Unit
19+
20+
foreign import username :: forall eff. HTMLHyperlinkElementUtils -> Eff (dom :: DOM | eff) String
21+
foreign import setUsername :: forall eff. String -> HTMLHyperlinkElementUtils -> Eff (dom :: DOM | eff) Unit
22+
23+
foreign import password :: forall eff. HTMLHyperlinkElementUtils -> Eff (dom :: DOM | eff) String
24+
foreign import setPassword :: forall eff. String -> HTMLHyperlinkElementUtils -> Eff (dom :: DOM | eff) Unit
25+
26+
foreign import host :: forall eff. HTMLHyperlinkElementUtils -> Eff (dom :: DOM | eff) String
27+
foreign import setHost :: forall eff. String -> HTMLHyperlinkElementUtils -> Eff (dom :: DOM | eff) Unit
28+
29+
foreign import hostname :: forall eff. HTMLHyperlinkElementUtils -> Eff (dom :: DOM | eff) String
30+
foreign import setHostname :: forall eff. String -> HTMLHyperlinkElementUtils -> Eff (dom :: DOM | eff) Unit
31+
32+
foreign import port :: forall eff. HTMLHyperlinkElementUtils -> Eff (dom :: DOM | eff) String
33+
foreign import setPort :: forall eff. String -> HTMLHyperlinkElementUtils -> Eff (dom :: DOM | eff) Unit
34+
35+
foreign import pathname :: forall eff. HTMLHyperlinkElementUtils -> Eff (dom :: DOM | eff) String
36+
foreign import setPathname :: forall eff. String -> HTMLHyperlinkElementUtils -> Eff (dom :: DOM | eff) Unit
37+
38+
foreign import search :: forall eff. HTMLHyperlinkElementUtils -> Eff (dom :: DOM | eff) String
39+
foreign import setSearch :: forall eff. String -> HTMLHyperlinkElementUtils -> Eff (dom :: DOM | eff) Unit
40+
41+
foreign import hash :: forall eff. HTMLHyperlinkElementUtils -> Eff (dom :: DOM | eff) String
42+
foreign import setHash :: forall eff. String -> HTMLHyperlinkElementUtils -> Eff (dom :: DOM | eff) Unit

src/DOM/HTML/Types.purs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ module DOM.HTML.Types
8282
, HTMLAnchorElement
8383
, htmlAnchorElementToHTMLElement
8484
, readHTMLAnchorElement
85+
, HTMLHyperlinkElementUtils
86+
, htmlAnchorElementToHTMLHyperlinkElementUtils
8587
, HTMLDataElement
8688
, htmlDataElementToHTMLElement
8789
, readHTMLDataElement
@@ -457,6 +459,11 @@ htmlAnchorElementToHTMLElement = U.unsafeCoerce
457459
readHTMLAnchorElement :: Foreign -> F HTMLAnchorElement
458460
readHTMLAnchorElement = unsafeReadTagged "HTMLAnchorElement"
459461

462+
foreign import data HTMLHyperlinkElementUtils :: Type
463+
464+
htmlAnchorElementToHTMLHyperlinkElementUtils :: HTMLAnchorElement -> HTMLHyperlinkElementUtils
465+
htmlAnchorElementToHTMLHyperlinkElementUtils = U.unsafeCoerce
466+
460467
foreign import data HTMLDataElement :: Type
461468

462469
htmlDataElementToHTMLElement :: HTMLDataElement -> HTMLElement

0 commit comments

Comments
 (0)