mirror of
https://github.com/videojs/video.js.git
synced 2025-04-25 12:24:45 +02:00
fix(extend): super_ should be available for backwards compatibility (#6329)
Fixes #6328
This commit is contained in:
parent
1545804959
commit
25d15d4b14
@ -44,6 +44,11 @@ const extend = function(superClass, subClassMethods = {}) {
|
|||||||
|
|
||||||
_inherits(subClass, superClass);
|
_inherits(subClass, superClass);
|
||||||
|
|
||||||
|
// this is needed for backward-compatibility and node compatibility.
|
||||||
|
if (superClass) {
|
||||||
|
subClass.super_ = superClass;
|
||||||
|
}
|
||||||
|
|
||||||
// Extend subObj's prototype with functions and other properties from props
|
// Extend subObj's prototype with functions and other properties from props
|
||||||
for (const name in methods) {
|
for (const name in methods) {
|
||||||
if (methods.hasOwnProperty(name)) {
|
if (methods.hasOwnProperty(name)) {
|
||||||
|
@ -16,3 +16,15 @@ QUnit.test('should add implicit parent constructor call', function(assert) {
|
|||||||
assert.ok(superCalled, 'super constructor called');
|
assert.ok(superCalled, 'super constructor called');
|
||||||
assert.ok(child.foo, 'child properties set');
|
assert.ok(child.foo, 'child properties set');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
QUnit.test('should have a super_ pointer', function(assert) {
|
||||||
|
const Parent = function() {};
|
||||||
|
const Child = extend(Parent, {
|
||||||
|
foo: 'bar'
|
||||||
|
});
|
||||||
|
|
||||||
|
const child = new Child();
|
||||||
|
|
||||||
|
assert.ok(child.foo, 'child properties set');
|
||||||
|
assert.equal(child.constructor.super_, Parent, 'super_ is present and equal to the super class');
|
||||||
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user