Skip to content

Commit 0aa27db

Browse files
authored
Merge pull request #18 from elliotdavies/feature/head
Add `head` function to HTMLDocument
2 parents ea3f850 + e6e3999 commit 0aa27db

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/Web/HTML/HTMLDocument.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
"use strict";
22

3+
exports._head = function (doc) {
4+
return function () {
5+
return doc.head;
6+
};
7+
};
8+
39
exports._body = function (doc) {
410
return function () {
511
return doc.body;
@@ -43,4 +49,4 @@ exports.setTitle = function (title) {
4349
return {};
4450
};
4551
};
46-
};
52+
};

src/Web/HTML/HTMLDocument.purs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module Web.HTML.HTMLDocument
1010
, toParentNode
1111
, toNonElementParentNode
1212
, toEventTarget
13+
, head
1314
, body
1415
, readyState
1516
, activeElement
@@ -68,6 +69,11 @@ toNonElementParentNode = unsafeCoerce
6869
toEventTarget :: HTMLDocument -> EventTarget
6970
toEventTarget = unsafeCoerce
7071

72+
foreign import _head :: HTMLDocument -> Effect (Nullable HTMLElement)
73+
74+
head :: HTMLDocument -> Effect (Maybe HTMLElement)
75+
head = map toMaybe <<< _head
76+
7177
foreign import _body :: HTMLDocument -> Effect (Nullable HTMLElement)
7278

7379
body :: HTMLDocument -> Effect (Maybe HTMLElement)
@@ -91,4 +97,4 @@ currentScript = map toMaybe <<< _currentScript
9197
foreign import referrer :: HTMLDocument -> Effect String
9298

9399
foreign import title :: HTMLDocument -> Effect String
94-
foreign import setTitle :: String -> HTMLDocument -> Effect Unit
100+
foreign import setTitle :: String -> HTMLDocument -> Effect Unit

0 commit comments

Comments
 (0)