mirror of
https://github.com/videojs/video.js.git
synced 2024-11-28 08:58:46 +02:00
@pavelhoral fixed subclassing without a constructor. closes #2308
This commit is contained in:
parent
440dfe92f8
commit
f9316fcda0
@ -58,6 +58,7 @@ CHANGELOG
|
||||
* @mischizzle fixed event.relatedTarget in Firefox ([view](https://github.com/videojs/video.js/pull/2025))
|
||||
* @mboles updated JSDoc comments everywhere to prepare for new docs ([view](https://github.com/videojs/video.js/pull/2270))
|
||||
* @mmcc added a currentTime tooltip to the progress handle ([view](https://github.com/videojs/video.js/pull/2255))
|
||||
* @pavelhoral fixed subclassing without a constructor ([view](https://github.com/videojs/video.js/pull/2308))
|
||||
|
||||
--------------------
|
||||
|
||||
|
@ -48,8 +48,10 @@ const extendsFn = function(superClass, subClassMethods={}) {
|
||||
};
|
||||
let methods = {};
|
||||
|
||||
if (subClassMethods.constructor !== Object.prototype.constructor) {
|
||||
subClass = subClassMethods.constructor;
|
||||
if (typeof subClassMethods === 'object') {
|
||||
if (subClassMethods.constructor !== Object.prototype.constructor) {
|
||||
subClass = subClassMethods.constructor;
|
||||
}
|
||||
methods = subClassMethods;
|
||||
} else if (typeof subClassMethods === 'function') {
|
||||
subClass = subClassMethods;
|
||||
|
16
test/unit/extends.test.js
Normal file
16
test/unit/extends.test.js
Normal file
@ -0,0 +1,16 @@
|
||||
import extendsFn from '../../src/js/extends.js';
|
||||
|
||||
q.module('extends.js');
|
||||
|
||||
test('should add implicit parent constructor call', function(){
|
||||
var superCalled = false;
|
||||
var Parent = function() {
|
||||
superCalled = true;
|
||||
};
|
||||
var Child = extendsFn(Parent, {
|
||||
foo: 'bar'
|
||||
});
|
||||
var child = new Child();
|
||||
ok(superCalled, 'super constructor called');
|
||||
ok(child.foo, 'child properties set');
|
||||
});
|
Loading…
Reference in New Issue
Block a user