Skip to content

Commit

Permalink
wrap helper in feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Garrett committed Feb 8, 2019
1 parent 86b2645 commit 93d42b1
Showing 1 changed file with 25 additions and 20 deletions.
45 changes: 25 additions & 20 deletions packages/external-helpers/lib/external-helpers.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,36 @@
import { DEBUG } from '@glimmer/env';
import { EMBER_NATIVE_DECORATOR_SUPPORT } from '@ember/canary-features';

const setPrototypeOf = Object.setPrototypeOf;

var nativeWrapperCache = new Map();
export let wrapNativeSuper;

// Super minimal version of Babel's wrapNativeSuper. We only use this for
// extending Function, for ComputedDecoratorImpl and AliasDecoratorImpl. We know
// we will never directly create an instance of these classes so no need to
// include `construct` code or other helpers.
export function wrapNativeSuper(Class) {
if (nativeWrapperCache.has(Class)) {
return nativeWrapperCache.get(Class);
}
if (EMBER_NATIVE_DECORATOR_SUPPORT) {
var nativeWrapperCache = new Map();

function Wrapper() {}
Wrapper.prototype = Object.create(Class.prototype, {
constructor: {
value: Wrapper,
enumerable: false,
writable: true,
configurable: true,
},
});
// Super minimal version of Babel's wrapNativeSuper. We only use this for
// extending Function, for ComputedDecoratorImpl and AliasDecoratorImpl. We know
// we will never directly create an instance of these classes so no need to
// include `construct` code or other helpers.
wrapNativeSuper = function(Class) {
if (nativeWrapperCache.has(Class)) {
return nativeWrapperCache.get(Class);
}

function Wrapper() {}
Wrapper.prototype = Object.create(Class.prototype, {
constructor: {
value: Wrapper,
enumerable: false,
writable: true,
configurable: true,
},
});

nativeWrapperCache.set(Class, Wrapper);
nativeWrapperCache.set(Class, Wrapper);

return setPrototypeOf(Wrapper, Class);
return setPrototypeOf(Wrapper, Class);
};
}

export function classCallCheck(instance, Constructor) {
Expand Down

0 comments on commit 93d42b1

Please sign in to comment.