ember-script
ember-script copied to clipboard
Inconsistent super behaviour
In coffescript you can call super
without any arguments and it'll be equivalent to passing all arguments to it.
class MyClass
myMethod: ->
super
translates into this:
var MyClass;
MyClass = (function() {
function MyClass() {}
MyClass.prototype.myMethod = function() {
return MyClass.__super__.myMethod.apply(this, arguments);
};
return MyClass;
})();
But in Emberscript super
without arguments doesn't even call the method. It just accesses the _super
property.
// Generated by EmberScript 0.0.14
var MyClass;
var get$ = Ember.get;
var set$ = Ember.set;
MyClass = Ember.Object.extend({
myMethod: function () {
return this._super;
}
});
Is that intentional?
This is a bug. It should have the CoffeeScript behavior but delegate to Ember's super method. On May 4, 2014 4:14 PM, "Pavel Pravosud" [email protected] wrote:
In coffescript you can call super without any arguments and it'll be equivalent to passing all arguments to it.
class MyClass myMethod: -> super
translates into this:
var MyClass; MyClass = (function() { function MyClass() {}
MyClass.prototype.myMethod = function() { return MyClass.super.myMethod.apply(this, arguments); };
return MyClass; })();
But in Emberscript super without arguments doesn't even call the method. It just accesses the _super property.
// Generated by EmberScript 0.0.14var MyClass;var get$ = Ember.get;var set$ = Ember.set;MyClass = Ember.Object.extend({ myMethod: function () { return this._super; }});
Is that intentional?
— Reply to this email directly or view it on GitHubhttps://github.com/ghempton/ember-script/issues/40 .
Another thing is that splat doesn't work around super.
For instance:
class MyClass
myMethod: ->
@otherMethod arguments...
translates into
return this.otherMethod.apply(null, [].slice.call(arguments));
but super arguments...
turns into
return this._super(arguments);
with splat being completely ignored.