Et2Widget: I figured out how to bind external listeners defined as template attributes directly on load.

Not sure we want to turn it on yet though.
This commit is contained in:
nathan 2022-06-23 11:00:47 -06:00
parent 1cc2cd5e3e
commit 3567a75e33

View File

@ -1405,13 +1405,15 @@ function transformAttributes(widget, mgr : et2_arrayMgr, attributes)
break;
}
// TODO: Figure out how to bind handlers directly, since we can do that now
/* (handlers can only be bound _after_ the widget is added to the DOM
// Bind handlers directly, since we can do that now. Event handlers still need to be defined
// in properties() as {type: Function}, but this will take care of the binding. This is
// separate from internal events.
// (handlers can only be bound _after_ the widget is added to the DOM
if(attribute.startsWith("on") && typeof attrValue == "function")
{
widget.addEventListener(attribute, attrValue);
//widget.updateComplete.then(() => addEventListener(attribute, attrValue));
}
*/
// Set as attribute or property, as appropriate. Don't set missing attributes.
if(widget.getAttributeNames().indexOf(attribute) >= 0 || property.reflect && attrValue)
{