cferdinandi / cferdinandi/events

Changing the base listener

Open
#10 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
61
Forks
13
PR merge metrics
No merged PRs in 30d

Description

## Changing the base listener

- We found out that there were some events that the window was not listening to. #9
- In order for these events to be captured, I had considered adding them to the document instead of the window, using a suitable condition.
- But instead it made much more sense to set the base listener directly as the document.
- Of course, it brought with it the question of how we can listen to the window events.
- It may seem counterintuitive at first glance, but after all, this is a delegation library. People may want to delegate the `div` element for it's child `span`. With this requirement, what I will say below has become meaningful.
- Structurally, there will still be a selector entry, but we will also require a delegate element, and this will be optional.

```js
events.(element, event, selector, callback)
```

- If element is left blank, it will be document by default.
- People will be able to type something like `events.(window, 'load', '', function (event) {` to listen for window events.
- They will also be able to properly add non-working events, such as `events.('mouseleave', '.selector', function (event) {`, thanks to the document.
- In addition to all these, "events.(document.querySelector ('#element'), 'click', '.selector', function (event) {" will be added to the project as an additional feature.

Contributor guide

Open the contributing guide

Research direction

Start by reading the current event-delegation API and implementation, then compare its listener target and call signature with the examples in this issue. Determine how document, window, and an optional delegate element should behave, and confirm the proposed API with tests for delegated and window events. Done means the behavior and public interface are unambiguous and covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.