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:
Scott Miles
2012-11-05 11:41:41 -08:00
parent e340cf7b7a
commit a88671ed23

View File

@@ -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]) {