mirror of
https://github.com/Polymer/polymer.git
synced 2025-02-25 18:55:30 -06:00
Steve's patch to make findController work in ShadowDOM context: it's no longer generalized, but at least it does what it's supposed to in polyfill, the generic notion of delegate-to-node-with-controller-property will need championing separately
This commit is contained in:
@@ -372,7 +372,7 @@ license that can be found in the LICENSE file.
|
||||
this[inMethod].apply(this, inArgs);
|
||||
}.bind(this), 0);
|
||||
};
|
||||
|
||||
|
||||
// decorate HTMLElementElement with toolkit API
|
||||
|
||||
HTMLElementElement.prototype.component = function(inUber) {
|
||||
@@ -469,17 +469,18 @@ license that can be found in the LICENSE file.
|
||||
// newer experimental event handler
|
||||
|
||||
var findController = function(inNode) {
|
||||
// find the nearest *containing* controller
|
||||
var n = inNode.parentNode;
|
||||
while (n) {
|
||||
if (n.controller) {
|
||||
return n.controller;
|
||||
// find the shadow root that contains inNode
|
||||
var n = inNode.changeling || inNode;
|
||||
while (n.parentNode && n.tagName !== 'SHADOW-ROOT') {
|
||||
n = n.parentNode;
|
||||
if (n.changeling) {
|
||||
n = n.changeling;
|
||||
}
|
||||
n = n.parentNode || n.host;
|
||||
}
|
||||
return n.host.controller;
|
||||
};
|
||||
|
||||
_ = function(inHandlerName) {
|
||||
var _ = function(inHandlerName) {
|
||||
var controller = findController(event.currentTarget);
|
||||
//console.log(inHandler, owner, event);
|
||||
if (controller && controller[inHandlerName]) {
|
||||
|
||||
Reference in New Issue
Block a user