Jdlrobson has uploaded a new change for review.
https://gerrit.wikimedia.org/r/159553
Change subject: Use OO for class inheritance
......................................................................
Use OO for class inheritance
Update extend wrapper.
Dependency: I37fa38b955104692ad544c71aaada9d48d209fcc
Change-Id: I3262d3bbe71b9b8e7dda5650727721db818c3ad4
---
M javascripts/common/Class.js
1 file changed, 3 insertions(+), 29 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Mantle
refs/changes/53/159553/1
diff --git a/javascripts/common/Class.js b/javascripts/common/Class.js
index 1597496..442fde9 100644
--- a/javascripts/common/Class.js
+++ b/javascripts/common/Class.js
@@ -16,38 +16,12 @@
function Child() {
return Parent.apply( this, arguments );
}
- function Surrogate() {}
- Surrogate.prototype = Parent.prototype;
- Child.prototype = new Surrogate();
- Child.prototype._parent = Parent.prototype;
-
- // http://ejohn.org/blog/simple-javascript-inheritance
- // Copy the properties over onto the new prototype
+ OO.inheritClass( Child, Parent );
for ( key in prototype ) {
- // Check if we're overwriting an existing function
- if ( typeof prototype[key] === 'function' && typeof
Parent.prototype[key] === 'function' ) {
- Child.prototype[key] = ( function( key, fn ) {
- return function() {
- var tmp = this._super, ret;
-
- // Add a new ._super() method
that is the same method
- // but on the super-class
- this._super =
Parent.prototype[key];
-
- // The method only need to be
bound temporarily, so we
- // remove it when we're done
executing
- ret = fn.apply(this, arguments);
- this._super = tmp;
-
- return ret;
- };
- } )( key, prototype[key] );
- } else {
- Child.prototype[key] = prototype[key];
- }
+ Child.prototype[key] = prototype[key];
}
-
Child.extend = extend;
+ Child.prototype._parent = Parent.prototype;
return Child;
}
--
To view, visit https://gerrit.wikimedia.org/r/159553
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I3262d3bbe71b9b8e7dda5650727721db818c3ad4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Mantle
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits