-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE strict-mode] Update VM for Strict Mode
Updates the Glimmer VM to the latest version, which includes strict mode. Strict mode is currently guarded behind a canary flag, but for the most part only involves changes to the VM. The biggest changes are to the template compiler's `compile` function, which has to change in order to still be functional as scope values must be provided in some way, and the resolver, which needs to provide keyword built-ins now in strict templates. Release notes for the VM: https://github.com/glimmerjs/glimmer-vm/releases/tag/v0.69.0
- Loading branch information
Chris Garrett
committed
Dec 10, 2020
1 parent
23ee5d1
commit db8abb2
Showing
16 changed files
with
440 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
packages/@ember/-internals/glimmer/tests/integration/components/strict-mode-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { | ||
moduleFor, | ||
RenderingTestCase, | ||
defineComponent, | ||
defineSimpleHelper, | ||
defineSimpleModifier, | ||
} from 'internal-test-helpers'; | ||
import { EMBER_STRICT_MODE } from '@ember/canary-features'; | ||
|
||
if (EMBER_STRICT_MODE) { | ||
moduleFor( | ||
'Strict Mode', | ||
class extends RenderingTestCase { | ||
'@test Can use a component in scope'() { | ||
let Foo = defineComponent({}, 'Hello, world!'); | ||
let Bar = defineComponent({ Foo }, '<Foo/>'); | ||
|
||
this.registerComponent('bar', { ComponentClass: Bar }); | ||
|
||
this.render('<Bar/>'); | ||
this.assertHTML('Hello, world!'); | ||
this.assertStableRerender(); | ||
} | ||
|
||
'@test Can use a custom helper in scope (in append position)'() { | ||
let foo = defineSimpleHelper(() => 'Hello, world!'); | ||
let Bar = defineComponent({ foo }, '{{foo}}'); | ||
|
||
this.registerComponent('bar', { ComponentClass: Bar }); | ||
|
||
this.render('<Bar/>'); | ||
this.assertHTML('Hello, world!'); | ||
this.assertStableRerender(); | ||
} | ||
|
||
'@test Can use a custom modifier in scope'() { | ||
let foo = defineSimpleModifier((element) => (element.innerHTML = 'Hello, world!')); | ||
let Bar = defineComponent({ foo }, '<div {{foo}}></div>'); | ||
|
||
this.registerComponent('bar', { ComponentClass: Bar }); | ||
|
||
this.render('<Bar/>'); | ||
this.assertHTML('<div>Hello, world!</div>'); | ||
this.assertStableRerender(); | ||
} | ||
|
||
'@test Can shadow keywords'() { | ||
let ifComponent = defineComponent({}, 'Hello, world!'); | ||
let Bar = defineComponent({ if: ifComponent }, '{{#if}}{{/if}}'); | ||
|
||
this.registerComponent('bar', { ComponentClass: Bar }); | ||
|
||
this.render('<Bar/>'); | ||
this.assertHTML('Hello, world!'); | ||
this.assertStableRerender(); | ||
} | ||
|
||
'@test Can use constant values in ambiguous helper/component position'() { | ||
let value = 'Hello, world!'; | ||
|
||
let Foo = defineComponent({ value }, '{{value}}'); | ||
|
||
this.registerComponent('foo', { ComponentClass: Foo }); | ||
|
||
this.render('<Foo/>'); | ||
this.assertHTML('Hello, world!'); | ||
this.assertStableRerender(); | ||
} | ||
|
||
'@test Can use inline if and unless in strict mode templates'() { | ||
let Foo = defineComponent({}, '{{if true "foo" "bar"}}{{unless true "foo" "bar"}}'); | ||
|
||
this.registerComponent('foo', { ComponentClass: Foo }); | ||
|
||
this.render('<Foo/>'); | ||
this.assertHTML('foobar'); | ||
this.assertStableRerender(); | ||
} | ||
} | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.