on:*
Event actions can be defined on any element with the following pattern:
on:<event>="hello KEML"
This is not an event handler in the traditional sense, because it does not imply any work being done.
This reads like the following:
- define
helloandKEMLas actions of typeevent - assign them to the output channel of
<event>
Event actions can then be used with the following pattern:
<feature>="hello"
This reads like the following:
- assign the
helloaction of typeeventto the input channel of<feature>
Again, this does not imply any work by itself - each individual feature will decide what to do with the input.
Info
Both sides are declarations — KEML has no event or signal system.
It runs in an event-driven browser, but itself is purely declarative: nothing is emitted or observed, and neither side is aware of the other.
Supported events¶
All event types are supported by KEML, regardless of their origin — KEML makes no distinction between them:
- native events
- events defined by KEML itself
- custom events emitted by other JavaScript on an element
KEML-defined events¶
reveal- element enters the viewportconceal- element leaves the viewportnavigate- History API transitionresult- successful server resultfailure- unsuccessful server resultdiscover- the element becomes known to the system (if theon:discoverattribute is removed and then added back, the event will be emitted again)attr:<name>- the attribute named<name>is added, removed, or changed
event: modifier¶
The output channel of event actions can be conditionally blocked by an event:
modifier:
event:<event>="key = value, otherKey = otherValue, truthyCheck"
This performs a shallow comparison between an event object and a specification provided in quotes.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | |
1 2 3 4 5 6 7 8 | |
Type something in and press `Ctrl+Enter` 😊
Parent handler¶
KEML does not interfere with normal browser event bubbling. This is not bubbling, but simple parent lookup.
on:* does not have to be set directly on the event emitting element; it can
also be on any of its parents.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | |
1 2 3 | |