Added "elements" and "events" attributes inheritance #430

merged 2 commits into from Mar 25, 2013

3 participants


I suggest merging parent events and elements with the child ones in Spine controller.
Let me show you how it will work:

class ParentContoller extends Spine.Controller
    '.parent-1': 'el_1'
    '.parent-2': 'el_2'

class ChildController extends ParentContoller
    '.child-2': 'el_2'
    '.child-3': 'el_3'

child = new ChildController()

child.el_1 # => $('.parent-1') element
child.el_2 # => $('.child-2')  element
child.el_3 # => $('.child-3')  element

The same thing with the events.
Any suggestions?

Spine JS Project member

I think this is a good idea, I have ran into this before and always thought I should be able to have a base controller class I could extend from and inherit events/elements. Any chance you can write a test to go along with the pull request?

Also I think @constructor.prototype.__proto__ could be written as @constructor.__super__, just a little bit shorter?


@cengebretson thanks for the reply. Do you think that the usage of super is really a good idea? Cause I haven't found any occurrences if it the Spine code. But there is no way I suppose to get the accesstor of the class.

If it's ok I'll fix the super issue and cover that with the tests.


Added specs for this pull request

Spine JS Project member


@cengebretson cengebretson merged commit 78eee04 into spine:master Mar 25, 2013
Spine JS Project member

thanks for the pull request, very much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment