purescript-jquery icon indicating copy to clipboard operation
purescript-jquery copied to clipboard

Selecting document, window, HTMLElements, et.c.

Open bergmark opened this issue 9 years ago • 1 comments

It looks like the only thing you can us as a selector is String, but it's heavily overloaded in jQuery. e.g. $(document).ready, $(window).on("popstate"), $(document.body), $($("why")). Has anyone given this any thought?

I'd suggest that special operations be completely separate functions, such as ready already is for $(document).ready, and we could have selectWindow and selectDocument for $(window) and $(document) respectively. This way it is possible to use these objects as normal elements, but you can certainly misuse these. Another option would be adding a type parameter to JQuery, that way we may be able to be more granular in type signatures.

In fay-jquery we chose to only allow elements, strings, and jquery objects as input to select.

bergmark avatar Aug 29 '16 19:08 bergmark

I'd be interested in adding the functionality you describe, either via multiple monomorphic functions like selectWindow, or type classes. I think I'd prefer the former though.

paf31 avatar Aug 30 '16 02:08 paf31