PDA

View Full Version : Determine if Class reference extends some other Class?



brian428
25 Jul 2012, 10:37 AM
Given a Class reference (not a class instance but the actual Class itself), is there a way to determine if that Class has some other Class somewhere in its inheritance chain?

In other words, say I write a CommonPanel class which extends Ext.panel.Panel. Then I create a MyPanel class which extends CommonPanel. If I have a Class reference for MyPanel, is there a way to determine that it's inheritance chain includes Ext.panel.Panel?

Again, not to be redundant, but I'm talking about looking at the actual Ext.Class object that defines the MyPanel class, not an instance of a MyPanel object.

Thanks,

Brian

scottmartin
25 Jul 2012, 11:13 AM
You can examine the superclass of the panel you created.

console.log(panel.superclass) and keep walking down .. there is xtypeChain / xtypeMap further down the chain.

Scott.

Tim Toady
25 Jul 2012, 11:14 AM
You could use instanceof on the prototypes I suppose. Ext even adds the superclass property to the prototype so you could go through manually as well..