1
0
mirror of https://github.com/videojs/video.js.git synced 2025-04-13 11:50:49 +02:00

fix(extend): super_ should be available for backwards compatibility (#6329)

Fixes #6328
This commit is contained in:
Gary Katsevman 2019-11-22 12:32:18 -05:00 committed by GitHub
parent 1545804959
commit 25d15d4b14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View File

@ -44,6 +44,11 @@ const extend = function(superClass, subClassMethods = {}) {
_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
for (const name in methods) {
if (methods.hasOwnProperty(name)) {

View File

@ -16,3 +16,15 @@ QUnit.test('should add implicit parent constructor call', function(assert) {
assert.ok(superCalled, 'super constructor called');
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');
});