1.0.0-beta.30 • Published 2 years ago

diffhtml-middleware-synthetic-events v1.0.0-beta.30

Weekly downloads
1
License
MIT
Repository
-
Last release
2 years ago

<±/> diffHTML Synthetic Events Middleware

Stable Version: 1.0.0-beta.30

Changes the event binding from inline event handlers like onclick = fn to use addEventListener. Hooks are attached to the body element and coordinated using event delegation.

Installation

npm install diffhtml-middleware-synthetic-events

Example

import { use, html, innerHTML } from 'diffhtml';
import syntheticEvents from 'diffhtml-middleware-synthetic-events';

use(syntheticEvents());

function render() {
  return html`
    <div onclick=${e => console.log(e)} />
  `;
}

// Binds the event on div using `addEventListener`.
innerHTML(document.body, render());

A good use case for this middleware is building a Chrome Extension where using inline event handlers is not possible. Supports non-bubbling events via the useCapture flag.

1.0.0-beta.30

2 years ago

1.0.0-beta.29

3 years ago

1.0.0-beta.28

3 years ago

1.0.0-beta.26

3 years ago

1.0.0-beta.27

3 years ago

1.0.0-beta.24

3 years ago

1.0.0-beta.25

3 years ago

1.0.0-beta.22

4 years ago

1.0.0-beta.23

3 years ago

1.0.0-beta.21

4 years ago

1.0.0-beta.20

4 years ago

1.0.0-beta.19

4 years ago

1.0.0-beta.18

5 years ago

1.0.0-beta.17

5 years ago

1.0.0-beta.16

5 years ago

1.0.0-beta.15

5 years ago

1.0.0-beta.14

5 years ago

1.0.0-beta.13

5 years ago

1.0.0-beta.12

5 years ago

1.0.0-beta.11

5 years ago

1.0.0-beta.9

8 years ago

1.0.0-beta.8

8 years ago

1.0.0-beta.7

8 years ago

1.0.0-beta.6

8 years ago

1.0.0-beta.5

8 years ago

1.0.0-beta.4

8 years ago

1.0.0-beta.3

8 years ago

1.0.0-beta.2

8 years ago

1.0.0-beta.1

8 years ago

1.0.0-beta

8 years ago