mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-14 00:33:09 +00:00
fixing callSuper (#3844)
* fixing callSuper * fixing lint * fixed unexpected alias for this
This commit is contained in:
parent
bdc97a8132
commit
aef73726ea
3 changed files with 27 additions and 3 deletions
|
|
@ -18,6 +18,7 @@
|
|||
onDeselect: function() {
|
||||
this.isEditing && this.exitEditing();
|
||||
this.selected = false;
|
||||
this.callSuper('onDeselect');
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -250,6 +250,13 @@
|
|||
*/
|
||||
_getLeftTopCoords: function() {
|
||||
return this.translateToOriginPoint(this.getCenterPoint(), 'left', 'top');
|
||||
},
|
||||
|
||||
/**
|
||||
* Callback; invoked right before object is about to go from active to inactive
|
||||
*/
|
||||
onDeselect: function() {
|
||||
/* NOOP */
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -51,10 +51,26 @@
|
|||
function Subclass() { }
|
||||
|
||||
function callSuper(methodName) {
|
||||
var fn = this.constructor.superclass.prototype[methodName];
|
||||
var parentMethod = null,
|
||||
_this = this;
|
||||
|
||||
// climb prototype chain to find method not equal to callee's method
|
||||
while (_this.constructor.superclass) {
|
||||
var superClassMethod = _this.constructor.superclass.prototype[methodName];
|
||||
if (_this[methodName] !== superClassMethod) {
|
||||
parentMethod = superClassMethod;
|
||||
break;
|
||||
}
|
||||
_this = _this.constructor.superclass.prototype;
|
||||
}
|
||||
|
||||
if (!parentMethod) {
|
||||
return console.log('tried to callSuper ' + methodName + ', method not found in prototype chain', this);
|
||||
}
|
||||
|
||||
return (arguments.length > 1)
|
||||
? fn.apply(this, slice.call(arguments, 1))
|
||||
: fn.call(this);
|
||||
? parentMethod.apply(this, slice.call(arguments, 1))
|
||||
: parentMethod.call(this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue