This repository was archived by the owner on Oct 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 56
Add HTMLHyperlinkElementUtils. #144
Merged
garyb
merged 2 commits into
purescript-deprecated:master
from
chexxor:add-htmlhyperlinkelementutils
Apr 13, 2018
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
"use strict"; | ||
|
||
exports.href = function (u) { | ||
return function () { | ||
return u.href; | ||
}; | ||
}; | ||
|
||
exports.setHref = function (href) { | ||
return function (u) { | ||
return function () { | ||
u.href = href; | ||
}; | ||
}; | ||
}; | ||
|
||
// ---------------------------------------------------------------------------- | ||
|
||
exports.origin = function (u) { | ||
return function () { | ||
return u.origin; | ||
}; | ||
}; | ||
|
||
// ---------------------------------------------------------------------------- | ||
|
||
exports.protocol = function (u) { | ||
return function () { | ||
return u.protocol; | ||
}; | ||
}; | ||
|
||
exports.setProtocol = function (protocol) { | ||
return function (u) { | ||
return function () { | ||
u.protocol = protocol; | ||
}; | ||
}; | ||
}; | ||
|
||
// ---------------------------------------------------------------------------- | ||
|
||
exports.username = function (u) { | ||
return function () { | ||
return u.username; | ||
}; | ||
}; | ||
|
||
exports.setUsername = function (username) { | ||
return function (u) { | ||
return function () { | ||
u.username = username; | ||
}; | ||
}; | ||
}; | ||
|
||
// ---------------------------------------------------------------------------- | ||
|
||
exports.password = function (u) { | ||
return function () { | ||
return u.password; | ||
}; | ||
}; | ||
|
||
exports.setPassword = function (password) { | ||
return function (u) { | ||
return function () { | ||
u.password = password; | ||
}; | ||
}; | ||
}; | ||
|
||
// ---------------------------------------------------------------------------- | ||
|
||
exports.host = function (u) { | ||
return function () { | ||
return u.host; | ||
}; | ||
}; | ||
|
||
exports.setHost = function (host) { | ||
return function (u) { | ||
return function () { | ||
u.host = host; | ||
}; | ||
}; | ||
}; | ||
|
||
// ---------------------------------------------------------------------------- | ||
|
||
exports.hostname = function (u) { | ||
return function () { | ||
return u.hostname; | ||
}; | ||
}; | ||
|
||
exports.setHostname = function (hostname) { | ||
return function (u) { | ||
return function () { | ||
u.hostname = hostname; | ||
}; | ||
}; | ||
}; | ||
|
||
// ---------------------------------------------------------------------------- | ||
|
||
exports.port = function (u) { | ||
return function () { | ||
return u.port; | ||
}; | ||
}; | ||
|
||
exports.setPort = function (port) { | ||
return function (u) { | ||
return function () { | ||
u.port = port; | ||
}; | ||
}; | ||
}; | ||
|
||
// ---------------------------------------------------------------------------- | ||
|
||
exports.pathname = function (u) { | ||
return function () { | ||
return u.pathname; | ||
}; | ||
}; | ||
|
||
exports.setPathname = function (pathname) { | ||
return function (u) { | ||
return function () { | ||
u.pathname = pathname; | ||
}; | ||
}; | ||
}; | ||
|
||
// ---------------------------------------------------------------------------- | ||
|
||
exports.search = function (u) { | ||
return function () { | ||
return u.search; | ||
}; | ||
}; | ||
|
||
exports.setSearch = function (search) { | ||
return function (u) { | ||
return function () { | ||
u.search = search; | ||
}; | ||
}; | ||
}; | ||
|
||
// ---------------------------------------------------------------------------- | ||
|
||
exports.hash = function (u) { | ||
return function () { | ||
return u.hash; | ||
}; | ||
}; | ||
|
||
exports.setHash = function (hash) { | ||
return function (u) { | ||
return function () { | ||
u.hash = hash; | ||
}; | ||
}; | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
-- https://html.spec.whatwg.org/multipage/links.html#htmlhyperlinkelementutils | ||
module DOM.HTML.HTMLHyperlinkElementUtils where | ||
|
||
import Prelude (Unit) | ||
|
||
import Control.Monad.Eff (Eff) | ||
|
||
import DOM (DOM) | ||
import DOM.HTML.Types (HTMLHyperlinkElementUtils) | ||
|
||
foreign import href :: forall eff. HTMLHyperlinkElementUtils -> Eff (dom :: DOM | eff) String | ||
foreign import setHref :: forall eff. String -> HTMLHyperlinkElementUtils -> Eff (dom :: DOM | eff) Unit | ||
|
||
foreign import origin :: forall eff. HTMLHyperlinkElementUtils -> Eff (dom :: DOM | eff) String | ||
|
||
foreign import protocol :: forall eff. HTMLHyperlinkElementUtils -> Eff (dom :: DOM | eff) String | ||
foreign import setProtocol :: forall eff. String -> HTMLHyperlinkElementUtils -> Eff (dom :: DOM | eff) Unit | ||
|
||
foreign import username :: forall eff. HTMLHyperlinkElementUtils -> Eff (dom :: DOM | eff) String | ||
foreign import setUsername :: forall eff. String -> HTMLHyperlinkElementUtils -> Eff (dom :: DOM | eff) Unit | ||
|
||
foreign import password :: forall eff. HTMLHyperlinkElementUtils -> Eff (dom :: DOM | eff) String | ||
foreign import setPassword :: forall eff. String -> HTMLHyperlinkElementUtils -> Eff (dom :: DOM | eff) Unit | ||
|
||
foreign import host :: forall eff. HTMLHyperlinkElementUtils -> Eff (dom :: DOM | eff) String | ||
foreign import setHost :: forall eff. String -> HTMLHyperlinkElementUtils -> Eff (dom :: DOM | eff) Unit | ||
|
||
foreign import hostname :: forall eff. HTMLHyperlinkElementUtils -> Eff (dom :: DOM | eff) String | ||
foreign import setHostname :: forall eff. String -> HTMLHyperlinkElementUtils -> Eff (dom :: DOM | eff) Unit | ||
|
||
foreign import port :: forall eff. HTMLHyperlinkElementUtils -> Eff (dom :: DOM | eff) String | ||
foreign import setPort :: forall eff. String -> HTMLHyperlinkElementUtils -> Eff (dom :: DOM | eff) Unit | ||
|
||
foreign import pathname :: forall eff. HTMLHyperlinkElementUtils -> Eff (dom :: DOM | eff) String | ||
foreign import setPathname :: forall eff. String -> HTMLHyperlinkElementUtils -> Eff (dom :: DOM | eff) Unit | ||
|
||
foreign import search :: forall eff. HTMLHyperlinkElementUtils -> Eff (dom :: DOM | eff) String | ||
foreign import setSearch :: forall eff. String -> HTMLHyperlinkElementUtils -> Eff (dom :: DOM | eff) Unit | ||
|
||
foreign import hash :: forall eff. HTMLHyperlinkElementUtils -> Eff (dom :: DOM | eff) String | ||
foreign import setHash :: forall eff. String -> HTMLHyperlinkElementUtils -> Eff (dom :: DOM | eff) Unit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we extend this comment a bit futher - the specs used in this library are generally from the w3c not the whatwg... however, in this case, after doing some research it turns out this might be the only place the IDL is actually stated for this API.
It's called
URLUtils
in the HTML5 spec, which points to a URL standard document, which now points to a whatwg document, which doesn't have the interface listed. As far as I can tell from the non-IDL descriptions in the w3c spec though, thisHTMLHyperlinkElementUtils
IDL has all the same elements as the now-missingURLUtils
API.So I'd suggest something like:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder which name we should use for this module and type, between "URLUtils" and "HTMLHyperlinkElementUtils". I feel like the latter term actually has a specification, which is good enough reason to choose this name rather than "URLUtils", and also it better fits the names of other types in this lib, like "HTMLAnchorElement".
Yeah, I was curious the relationship between w3 and whatwg's specs.
BTW, I chose the whatwg spec because that's the one MDN references:
Source: https://developer.mozilla.org/en-US/docs/Web/API/HTMLHyperlinkElementUtils/href
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I understand it, the whatwg/living standard stuff is basically "encode what is commonly available in a spec" 😄 (rather than the w3c specs that describe how things are intended to work, before an implementation exists). I said in the readme we were going off the w3c specs, but maybe the living standard(s) would be more practical.
Really I was just hoping to avoid implementing browser quirks in the API / experimental stuff that is not widely implemented and agreed upon yet. LS would probably also satisfy that.