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);
|
this[inMethod].apply(this, inArgs);
|
||||||
}.bind(this), 0);
|
}.bind(this), 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
// decorate HTMLElementElement with toolkit API
|
// decorate HTMLElementElement with toolkit API
|
||||||
|
|
||||||
HTMLElementElement.prototype.component = function(inUber) {
|
HTMLElementElement.prototype.component = function(inUber) {
|
||||||
@@ -469,17 +469,18 @@ license that can be found in the LICENSE file.
|
|||||||
// newer experimental event handler
|
// newer experimental event handler
|
||||||
|
|
||||||
var findController = function(inNode) {
|
var findController = function(inNode) {
|
||||||
// find the nearest *containing* controller
|
// find the shadow root that contains inNode
|
||||||
var n = inNode.parentNode;
|
var n = inNode.changeling || inNode;
|
||||||
while (n) {
|
while (n.parentNode && n.tagName !== 'SHADOW-ROOT') {
|
||||||
if (n.controller) {
|
n = n.parentNode;
|
||||||
return n.controller;
|
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);
|
var controller = findController(event.currentTarget);
|
||||||
//console.log(inHandler, owner, event);
|
//console.log(inHandler, owner, event);
|
||||||
if (controller && controller[inHandlerName]) {
|
if (controller && controller[inHandlerName]) {
|
||||||
|
|||||||
Reference in New Issue
Block a user