Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(FEC-11038): decorator API called with incorrect this(proxy) instead of the activeDecorator #546

Merged
merged 18 commits into from
Mar 10, 2021
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/engines/engine-decorator.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,16 @@ class EngineDecorator extends FakeEventTarget implements IEngineDecorator {
return this._listeners;
}
const activeDecorator = this._pluginDecorators.find(decorator => decorator.active);
// $FlowFixMe
return activeDecorator && prop in activeDecorator ? activeDecorator[prop] : obj[prop];
const isGetter = (object, property) => {
const descriptor = Object.getOwnPropertyDescriptor(object, property);
return descriptor && !!descriptor['get'];
};
const target = activeDecorator && prop in activeDecorator ? activeDecorator : obj;
return isGetter(target.constructor.prototype, prop)
? // $FlowFixMe
target[prop]
: // $FlowFixMe
(...args) => target[prop](...args);
},
set: (obj, prop, value) => {
const activeDecorator = this._pluginDecorators.find(decorator => prop in decorator && decorator.active);
Expand Down
3 changes: 1 addition & 2 deletions src/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -1700,8 +1700,7 @@ export default class Player extends FakeEventTarget {
this._appendEngineEl();
} else {
if (this._engine.id === Engine.id) {
// The restoring must be done by the engine itself not by the proxy (engine decorator if exists) to make sure the engine events fired by the engine itself.
this._engine.restore.call(this._engine._engine || this._engine, source, this._config);
this._engine.restore.call(this._engine, source, this._config);
Yuvalke marked this conversation as resolved.
Show resolved Hide resolved
} else {
this._engine.destroy();
this._createEngine(Engine, source);
Expand Down