From 25d15d4b1487e84b493cb055cfa30533fce98ef9 Mon Sep 17 00:00:00 2001 From: Gary Katsevman Date: Fri, 22 Nov 2019 12:32:18 -0500 Subject: [PATCH] fix(extend): super_ should be available for backwards compatibility (#6329) Fixes #6328 --- src/js/extend.js | 5 +++++ test/unit/extend.test.js | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/js/extend.js b/src/js/extend.js index 0dd5daf192..098129e4ce 100644 --- a/src/js/extend.js +++ b/src/js/extend.js @@ -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)) { diff --git a/test/unit/extend.test.js b/test/unit/extend.test.js index 84e034b961..8764e0b545 100644 --- a/test/unit/extend.test.js +++ b/test/unit/extend.test.js @@ -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'); +});