Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upAPI idea: `contains` predicate on Json.Decode.Value #868
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
process-bot
May 17, 2017
Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!
Here is what to expect next, and if anyone wants to comment, keep these things in mind.
process-bot
commented
May 17, 2017
|
Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it! Here is what to expect next, and if anyone wants to comment, keep these things in mind. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
97jaz
May 17, 2017
I see that the checklist page says that issues are for bugs, so maybe this doesn't belong here? I created this after reading the text in #322 that says "Open a separate issue for your particular idea." So... I'm not sure if this belongs here or not.
97jaz
commented
May 17, 2017
|
I see that the checklist page says that issues are for bugs, so maybe this doesn't belong here? I created this after reading the text in #322 that says "Open a separate issue for your particular idea." So... I'm not sure if this belongs here or not. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
97jaz
commented
May 17, 2017
|
As this is no longer a concrete API idea, I'm just going to close it. |
97jaz commentedMay 17, 2017
•
edited
Edited 1 time
-
97jaz
edited May 17, 2017 (most recent)
A fairly common need when creating various kinds of menus is to be able to determine, when receiving a
blurorfocusoutevent on your menu's outermost element, whether focus has shifted to a descendant of that element (in which case you want to keep the menu open) or not (in which case you want to close the menu).There are a number of ways to accomplish the same goal, but the most straightforward way I know of -- though I could be overlooking something -- is to ask whether the
relatedTargetof afocusoutevent is a descendant of thetarget. I don't know of a way to do this in Elm today without using aNativemodule.It looks like it should be very simple[see update below] to wrap the DOM'sNode.containsmethod as a function onJson.Decode.Values so that it could be used in decoders.I'd be happy to put together a PR, but I figured I should check first to see whether there's a better way to accomplish the same goal or, even if there isn't, this idea doesn't appeal to the maintainers.
Update: sorry, I should have thought about this a bit longer before posting it. The
containspredicate only makes sense on DOM nodes, not onValues generally. My initial thought is that DOM events need a richer representation in Elm. But given the current representation, the simplest -- though not very appealing -- way to handle this would be to offer a function with a type like:Value -> Maybe Node, but it's... hard to like that.