Skip to content

Commit

Permalink
Merge pull request #18 from elliotdavies/feature/head
Browse files Browse the repository at this point in the history
Add `head` function to HTMLDocument
  • Loading branch information
garyb authored Sep 15, 2019
2 parents ea3f850 + e6e3999 commit 0aa27db
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/Web/HTML/HTMLDocument.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
"use strict";

exports._head = function (doc) {
return function () {
return doc.head;
};
};

exports._body = function (doc) {
return function () {
return doc.body;
Expand Down Expand Up @@ -43,4 +49,4 @@ exports.setTitle = function (title) {
return {};
};
};
};
};
8 changes: 7 additions & 1 deletion src/Web/HTML/HTMLDocument.purs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module Web.HTML.HTMLDocument
, toParentNode
, toNonElementParentNode
, toEventTarget
, head
, body
, readyState
, activeElement
Expand Down Expand Up @@ -68,6 +69,11 @@ toNonElementParentNode = unsafeCoerce
toEventTarget :: HTMLDocument -> EventTarget
toEventTarget = unsafeCoerce

foreign import _head :: HTMLDocument -> Effect (Nullable HTMLElement)

head :: HTMLDocument -> Effect (Maybe HTMLElement)
head = map toMaybe <<< _head

foreign import _body :: HTMLDocument -> Effect (Nullable HTMLElement)

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

foreign import title :: HTMLDocument -> Effect String
foreign import setTitle :: String -> HTMLDocument -> Effect Unit
foreign import setTitle :: String -> HTMLDocument -> Effect Unit

0 comments on commit 0aa27db

Please sign in to comment.