Skip to content

How the Component Handler works

Jonathan Garbee edited this page Apr 30, 2015 · 4 revisions

How the Component Handler works

The component handler is a powerful object that makes sure the javascript runs on your page against the elements it is supposed to. Here is a quick run-down of its execution (to be expanded later to be more official and stuff.)

  1. The component handler itself is created with an empty registry.
  2. Objects for components are added to the code. Each registers itself to the registry. The registry requires:
    • The object to run the element through.
    • A string to identify this component through. Should be unique throughout all components.
    • The classname to look for on an element for this component to be initialized.
  3. The upgradeAllRegistered() method is called from the handler.
    • In short this goes over all registered components. Queries for all nodes with the provided CSS class. Loops over those and instantiates them one-by-one. When the upgrade is done on a node, the upgraded object is added to the dataset. This object contains a comma separated list of component classAsString properties to identify which upgrades have been done.
Clone this wiki locally