fix(Structures): allow multiple extensions by checking prototype chain (#3217)

This commit is contained in:
Dragoteryx
2019-04-21 09:34:12 +02:00
committed by SpaceEEC
parent 1514df0f87
commit 52b4f09e58

View File

@@ -55,8 +55,8 @@ class Structures {
throw new TypeError(`The extender function must return the extended structure class/prototype ${received}.`); throw new TypeError(`The extender function must return the extended structure class/prototype ${received}.`);
} }
const prototype = Object.getPrototypeOf(extended); if (!(extended.prototype instanceof structures[structure])) {
if (prototype !== structures[structure]) { const prototype = Object.getPrototypeOf(extended);
const received = `${extended.name || 'unnamed'}${prototype.name ? ` extends ${prototype.name}` : ''}`; const received = `${extended.name || 'unnamed'}${prototype.name ? ` extends ${prototype.name}` : ''}`;
throw new Error( throw new Error(
'The class/prototype returned from the extender function must extend the existing structure class/prototype' + 'The class/prototype returned from the extender function must extend the existing structure class/prototype' +