matthewp / corset

Declarative data bindings, bring your own backend.
https://corset.dev/
BSD 2-Clause "Simplified" License
277 stars 2 forks source link

Needed feature - A way to bind global (document, window, etc.) event listeners to the sheet. #180

Closed ghost closed 2 years ago

ghost commented 2 years ago

I feel as if there are a lot of cases where binding an event listener to the document or window objects is necessary for the functionality of the website to work. I have definitely run into this necessity in a couple of my little side projects.

I propose that a new event-target property (already discussed briefly with Matthew) is added to allow for this functionality. This should be a clean approach to the problem.

body {
  event: custom ${() => this.count++};
  event-target: ${window};
}
matthewp commented 2 years ago

Added in https://github.com/matthewp/corset/commit/56cf52ec6a0d3f7d27d6df85e9e4cf401421cd3a