[ http://issues.apache.org/jira/browse/XAP-80?page=comments#action_12448648 ] Turyn, Michael commented on XAP-80: -----------------------------------
Agreed; this is a problem caused by the fact that "this.superclass" is _not_ context-sensitive when called with call(ths,...) or apply(this,...). If a way could be found to determine the object a function call actually came from, we could create a superclass() method that would do the right thing. I will give this a little time, but my guess is that we can't, since JS goes through a lot to obscure this. The member "arguments.callee" in every function knows which function is actually being called (it knows it's in me.prototype.prototype.foo(), not me.foo() if the latter doesn't exist) but I don't think there's a way of going from the member to the object that owns it. Otherwise, I'll just go through the code and replace the this.superclass with the explicit object references. > setupClassAsSubclassOf() has some unexpected behavior > ----------------------------------------------------- > > Key: XAP-80 > URL: http://issues.apache.org/jira/browse/XAP-80 > Project: XAP > Issue Type: Bug > Reporter: James Margaris > > In TableBridge I have the following: > xap.bridges.dojo.TableBridge.prototype.init = function() { > this.superclass.init.call(this); > //add listener last so we don't fire for the initial set > dojo.event.connect(this.getPeer(), > "onActivateRow",this,"onActivateRow"); > dojo.event.connect(this.getPeer(), "onSelectRow",this,"onSelectRow"); > dojo.event.connect(this.getPeer(), > "onDeselectRow",this,"onDeselectRow"); > dojo.event.connect(this.getPeer(), "onExpandRow",this,"onExpandRow"); > } > Now I set up a subclass of table bridge that does NOT override init.: > /** > * @fileoverview > * > * A bridge class with dojo toolkit box panel peer. > */ > > xap.bridges.dojo.TreeBridge= function() { > xap.bridges.dojo.TableBridge.call(this); > } > Xap.setupClassAsSubclassOf( > "xap.bridges.dojo.TreeBridge", > "xap.bridges.dojo.TableBridge" > > ); > When you map a tag to treeBridge and run, you get an infinite recursion. > If I change the init call in TableBridge to do: > xap.bridges.dojo.DojoWidgetBridge.prototype.init.call(this); > It works fine. > It seems to me that what is happening here: > We look for an init() and find one in TreeBridge that is actually the version > from TableBridge > We run that init > The this.superclass call, since we are technically in TreeBridge, maps to the > TableBridge (?) method > Some recursion occurs ?? > We should look at how dojo works, there instead of: > this.superclass > You do: > xap.bridges.TreeBridge.superclass > Avoiding the use of "this" which has some context issues.. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
