mirror of
https://github.com/Polymer/polymer.git
synced 2025-02-25 18:55:30 -06:00
add asyncMethod component API, use it to make fireEvent function asynchronously (to avoid stack explosions when cascading events)
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user