-
Couldn't load subscription status.
- Fork 5k
How the Component Handler works
Jonathan Garbee edited this page Apr 30, 2015
·
4 revisions
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.)
- The component handler itself is created with an empty registry.
- 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.
- 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
classAsStringproperties to identify which upgrades have been done.
- 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
Copyright Google, 2015. Licensed under an Apache-2 license.