Translation
You can always define properties using property descriptor objects. However, the translation concept provides a set of rules for translating the definition that does not match property descriptor structure (an object with get
, set
, connect
or observe
methods).
The translation expands shorter syntax or applies built-in factories using passed values. The translation is done in the following order:
render
key descriptor with value as a function translates torender
factory:The descriptor value as a function translates to the descriptor with get method:
The descriptor value set as a primitive or an array instance translates to
property
factory:
The translation process does not change the original structure of the definition. The library translates it when an element is defined. As the result, custom element definition can be just a simple structure of default values and methods without external dependencies. For example, the definition in the original shape can be extracted for unit tests.
Instead of explicit usage of the property
and render
factories:
You can write a component definition without them (using translation):
Last updated
Was this helpful?