Skip to content

Commit

Permalink
Steve's patch to make findController work in ShadowDOM context: it's …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
Scott Miles committed Nov 5, 2012
1 parent e340cf7 commit a88671e
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/g-component.html
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@
this[inMethod].apply(this, inArgs);
}.bind(this), 0);
};

// decorate HTMLElementElement with toolkit API

HTMLElementElement.prototype.component = function(inUber) {
Expand Down Expand Up @@ -469,17 +469,18 @@
// 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]) {
Expand Down

1 comment on commit a88671e

@sjmiles
Copy link
Contributor

@sjmiles sjmiles commented on a88671e Nov 5, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes #30

Please sign in to comment.