Skip to content

Commit

Permalink
Fix Symbol.hasInstance not added on mixin
Browse files Browse the repository at this point in the history
  • Loading branch information
aedart committed Feb 6, 2024
1 parent 026feec commit 0bdb6f4
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions packages/support/src/mixins/mixins/HasInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ export const HasInstance = function(mixin: Mixin): Mixin
{
// The following source code is an adaptation of Justin Fagnani's "mixwith.js" (Apache License 2.0)
// @see https://github.com/justinfagnani/mixwith.js

if (!Reflect.has(mixin, Symbol.hasInstance)) {
Reflect.defineProperty(mixin, Symbol.hasInstance, {
value(instance) {
return hasMixin(instance, mixin);
},
})

// Skip if mixin already has Symbol.hasInstance
if (Object.hasOwn(mixin, Symbol.hasInstance)) {
return mixin;
}

return mixin;
// Otherwise, define the Symbol.hasInstance
return Object.defineProperty(mixin, Symbol.hasInstance, {
value: (instance: object) => {
return hasMixin(instance, mixin);
},
});
}

0 comments on commit 0bdb6f4

Please sign in to comment.