Invokers

Keith Cirkel demonstrates a brand new concept (requires Chrome Canary and the Experimental Web Platform Features flag right now) called Invokers, a proposal from the Open UI group that is polyfillable. You “invoke” events directly on a specific element in the DOM:

<button
  invoketarget="counter"
  invokeaction="increment"> + </button>

<h1 id="el">0</h1>Code language: HTML, XML (xml)

Then you can listen for the invoke event on that element.

el.addEventListener("invoke", (e) => {
  console.log(e.action); // increment
  // do stuff
});Code language: JavaScript (javascript)

Adding interactive functionality to HTML attributes seems to be aligned with the last decade of JavaScript frameworks.

It's time to take your JavaScript to the next level

Leave a Reply

Your email address will not be published. Required fields are marked *

Did you know?

Frontend Masters Donates to open source projects. $363,806 contributed to date.