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

Merged
merged 2 commits into from Mar 25, 2013

3 participants

@umate

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
  elements:
    '.parent-1': 'el_1'
    '.parent-2': 'el_2'

class ChildController extends ParentContoller
  elements:
    '.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?

@cengebretson
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?

@umate

@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.

@umate

Added specs for this pull request

@aeischeid
Spine JS Project member

Nice!

@cengebretson cengebretson merged commit 78eee04 into spine:master Mar 25, 2013
@cengebretson
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