mirror of
https://github.com/Polymer/polymer.git
synced 2026-08-19 01:14:44 -05:00
Apply listeners in constructor rather than ready
Fixes #4394. This change allows elements to have "first crack" at their own events (via the `listeners` object) before handlers registered via `on-*` see events. This is both more expected and fixes an inconsistency with 1.x.
This commit is contained in:
@@ -81,6 +81,11 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
/** @type {Object<string, Function>} */
|
||||
this._debouncers;
|
||||
this.created();
|
||||
// Ensure listeners are applied immediately so that they are
|
||||
// added before declarative event listeners. This allows an element to
|
||||
// decorate itself via an event prior to any declarative listeners
|
||||
// seeing the event. Note, this ensures compatibility with 1.x ordering.
|
||||
this._applyListeners();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -180,7 +185,6 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
*/
|
||||
ready() {
|
||||
this._ensureAttributes();
|
||||
this._applyListeners();
|
||||
super.ready();
|
||||
}
|
||||
|
||||
|
||||
@@ -579,7 +579,13 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
*/
|
||||
setTouchAction: function(node, value) {
|
||||
if (HAS_NATIVE_TA) {
|
||||
node.style.touchAction = value;
|
||||
// NOTE: add touchAction async so that events can be added in
|
||||
// custom element constructors. Otherwise we run afoult of custom
|
||||
// elements restriction against settings attributes (style) in the
|
||||
// constructor.
|
||||
Polymer.Async.microTask.run(() => {
|
||||
node.style.touchAction = value;
|
||||
});
|
||||
}
|
||||
node[TOUCH_ACTION] = value;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user