-
Notifications
You must be signed in to change notification settings - Fork 24
Add HTMLDialogElement #77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
I run into a similar issue of needing this dialog element. Any possibility of merging the PR? |
| foreign import open :: HTMLDialogElement -> Effect Boolean | ||
| foreign import setOpen :: Boolean -> HTMLDialogElement -> Effect Unit | ||
|
|
||
| foreign import returnValue :: HTMLDialogElement -> Effect String |
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.
It appears this should be something like:
foreign import _returnValue :: HTMLDialogElement -> Effect (Nullable String)
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.
MDN says it’s a string though see https://developer.mozilla.org/en-US/docs/Web/API/HTMLDialogElement/returnValue
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.
The PR template includes:
Although MDN is a great resource, it is not a suitable reference for this project.
That being said, I believe it is correct.
I think I misinterpreted the following from sections in the spec on close(returnValue) and requestClose(returnValue):
If returnValue is not given, then set it to null.
Upon reading further just now, I saw this:
When a dialog element subject is to be closed, with null or a string result and an Element or null source, run these steps:
[...]
9. If result is not null, then set subject's returnValue attribute to result.
[...]
Sorry for the noise.
|
|
||
| foreign import _close :: Nullable String -> HTMLDialogElement -> Effect Unit | ||
|
|
||
| close :: Maybe String -> HTMLDialogElement -> Effect Unit |
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.
Explicitly passing null to HTMLDialogElement.close results in the returnValue being set to the string "null", which seems surprising at least.
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.
It seems the method is expecting undefined or string so the input type should be refined to Undefined String
|
Only things I see missing here are |
The behavior of |
Could you open a followup to this? I don't see @kgmt0 active in the replies and the original pull request is quite old. |
|
Since there is no equivalent of Data.Undefined it seems the best way forward is to modify the foreign code to treat null as undefined. |
Prerequisites
purescript-webprojects. Although MDN is a great resource, it is not a suitable reference for this project.https://html.spec.whatwg.org/#the-dialog-element
Description of the change
This adds a new module for
HTMLDialogElement, which corresponds to<dialog>.Checklist: