Hype DataDecorator (master) doxdox documentation

Project for getting reactivity and feedback directly in Tumult Hype 4 using the additional HTML-attributes panel for options.

# getRunningObserver()

This function returns a list of all running observer. For testing might get removed.

Returns

Return array with active observer across all Hype documents

# mapAttributeToSelector(key, selector, callback, options)

This function maps a attribute to selector and fires the given callback on all its decendants. This function allows for more flexebility in mapping. and the callback is optional and has setContent as fallback. The value of the attribute will be forwarded to the callback(s) as event.value

Parameters

Name Types Description
key String This is the attribute we want to map
selector String This is the selector we want to forward the value to
callback String This is an decorator callback and is optional
options Object These options are a mixin and still not used here

# mapDataAttribute(key, callback, options)

This function is a proxy to HypeDataDecorator.mapAttributeToSelector and and sets the attribute data-YOURKEY and maps it to the class .YOURKEY serving as a shortcut. The callback is optional and has setContent as fallback. The value of the data-YOURKEY will be forwarded to the callback(s) as event.value

Parameters

Name Types Description
key String This is the data attribute we want to map
callback String This is an decorator callback and is optional
options Object These options are a mixin and still not used here

# observeBySelector(selector, callback, options)

This function maps sets up an HTML element observer that match a selector and a attribute. By default the style attribute on the HTML element is observered for change. To determine other attributes use the options as {attributesFilter: ['a','b']}. If one needs to listen to all attributes set options as {attributesFilter: []}

Parameters

Name Types Description
selector String This is the selector that determin
callback String This is an decorator callback and is optional
options Object These options are a mixin and allow setting the attributeFilter

# registerElementDecorator(name, callback)

This function allow to register a element decorator callback by name. Having named callbacks allows to chain them and reuse them if wanted.

Parameters

Name Types Description
name String This is the attribute we want to map
callback Function This is the function to be registered as an decorator

# setContent(element, value)

This function allows to set innerHTML in a save way. Meaning it helps in preventing undesired destruction of Hype managed nodes this is also set as the default decorator and registers as a callback

Parameters

Name Types Description
element HTMLDivElement This is the element to set the content on
value String The value determins what is inserted to innerHTML