paf31 / purescript-jquery

Type declarations for jQuery
MIT License
30 stars 28 forks source link

Selecting document, window, HTMLElements, et.c. #29

Open bergmark opened 8 years ago

bergmark commented 8 years ago

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.

paf31 commented 8 years ago

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.