From 215b6de577e5e90883e76c7a7e2b8187ddfa45cf Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Fri, 12 Jul 2019 15:11:30 -0400 Subject: [PATCH 1/3] [FEATURE ember-glimmer-set-component-template] Enable by default. --- blueprints/component/index.js | 4 +--- packages/@ember/canary-features/index.ts | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/blueprints/component/index.js b/blueprints/component/index.js index a5d8fdc9fa8..e93a0089792 100644 --- a/blueprints/component/index.js +++ b/blueprints/component/index.js @@ -14,12 +14,10 @@ const OCTANE = process.env.EMBER_VERSION === 'octane'; // TODO: this should be reading from the @ember/canary-features module // need to refactor broccoli/features.js to be able to work more similarly // to https://github.com/emberjs/data/pull/6231 -const EMBER_GLIMMER_SET_COMPONENT_TEMPLATE = OCTANE; +const EMBER_GLIMMER_SET_COMPONENT_TEMPLATE = true; // intentionally avoiding use-edition-detector module.exports = { - EMBER_GLIMMER_SET_COMPONENT_TEMPLATE, - description: 'Generates a component.', availableOptions: [ diff --git a/packages/@ember/canary-features/index.ts b/packages/@ember/canary-features/index.ts index 9099973e3d8..4df22887a0d 100644 --- a/packages/@ember/canary-features/index.ts +++ b/packages/@ember/canary-features/index.ts @@ -23,7 +23,7 @@ export const DEFAULT_FEATURES = { EMBER_GLIMMER_FN_HELPER: true, EMBER_CUSTOM_COMPONENT_ARG_PROXY: true, EMBER_FRAMEWORK_OBJECT_OWNER_ARGUMENT: true, - EMBER_GLIMMER_SET_COMPONENT_TEMPLATE: null, + EMBER_GLIMMER_SET_COMPONENT_TEMPLATE: true, }; /** From 77b4bc6c14f603de7d2ff1a8b2d8d5f901a8edd4 Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Wed, 31 Jul 2019 16:31:58 -0400 Subject: [PATCH 2/3] Avoid assertions for Symbol when not present. Co-authored-by: Godfrey Chan --- .../integration/components/component-template-test.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/@ember/-internals/glimmer/tests/integration/components/component-template-test.js b/packages/@ember/-internals/glimmer/tests/integration/components/component-template-test.js index ead2666701c..e569df0789e 100644 --- a/packages/@ember/-internals/glimmer/tests/integration/components/component-template-test.js +++ b/packages/@ember/-internals/glimmer/tests/integration/components/component-template-test.js @@ -4,6 +4,7 @@ import { EMBER_GLIMMER_SET_COMPONENT_TEMPLATE, EMBER_MODULE_UNIFICATION, } from '@ember/canary-features'; +import { HAS_NATIVE_SYMBOL } from '@ember/-internals/utils'; import { Component, compile } from '../../utils/helpers'; import { setComponentTemplate, getComponentTemplate } from '../../..'; @@ -74,9 +75,11 @@ if (EMBER_GLIMMER_SET_COMPONENT_TEMPLATE) { setComponentTemplate(compile('foo'), 'foo'); }, /Cannot call `setComponentTemplate` on `foo`/); - expectAssertion(() => { - setComponentTemplate(compile('foo'), Symbol('foo')); - }, /Cannot call `setComponentTemplate` on `Symbol\(foo\)`/); + if (HAS_NATIVE_SYMBOL) { + expectAssertion(() => { + setComponentTemplate(compile('foo'), Symbol('foo')); + }, /Cannot call `setComponentTemplate` on `Symbol\(foo\)`/); + } } '@test calling it twice on the same object asserts'() { From 7a3175db82b4be8f9eae9e68d3125e63e5ea1493 Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Wed, 31 Jul 2019 18:35:44 -0400 Subject: [PATCH 3/3] [BUGFIX beta] Reduce false positives for HAS_NATIVE_SYMBOL with polyfills. Prior to this change the core.js polyfills would be detected as "native symbols" (they monkey patch `Object.prototype.toString` to avoid detection by our prior check). Co-authored-by: Godfrey Chan --- packages/@ember/-internals/utils/lib/symbol-utils.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/@ember/-internals/utils/lib/symbol-utils.ts b/packages/@ember/-internals/utils/lib/symbol-utils.ts index 2ef59bca6a5..324aaa1ed15 100644 --- a/packages/@ember/-internals/utils/lib/symbol-utils.ts +++ b/packages/@ember/-internals/utils/lib/symbol-utils.ts @@ -3,7 +3,5 @@ export const HAS_NATIVE_SYMBOL = (function() { return false; } - // use `Object`'s `.toString` directly to prevent us from detecting - // polyfills as native - return Object.prototype.toString.call(Symbol()) === '[object Symbol]'; + return typeof Symbol() === 'symbol'; })();