add asyncMethod component API, use it to make fireEvent function asynchronously (to avoid stack explosions when cascading events)

This commit is contained in:
Scott Miles
2012-10-26 14:55:51 -07:00
parent f3ef76f127
commit e7dcbd8ffb

View File

@@ -353,6 +353,31 @@ license that can be found in the LICENSE file.
}
};
// per-instance
var automate = function(inAttributes, inPublished, inDelegates) {
bindAttrs.call(this, inAttributes.attributes);
bindEvents.call(this, inAttributes.handlers);
bindProperties.call(this, inPublished);
bindDelegates.call(this, inDelegates);
};
// fireEvent impl
var fireEvent = function(inType, inDetail) {
this.asyncMethod("dispatchEvent", [
new CustomEvent(inType, {bubbles: true, detail: inDetail})
]);
};
// asyncMethod impl
var asyncMethod = function(inMethod, inArgs) {
window.setTimeout(function() {
this[inMethod].apply(this, inArgs);
}.bind(this), 0);
};
// decorate HTMLElementElement with toolkit API
HTMLElementElement.prototype.component = function(inUber) {