You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 8, 2024. It is now read-only.
On Ember 3.25, strict mode is supported but babel-plugin-modules-api-polyfill is still needed. Under those conditions, trying to use any of the framework-provided helpers in strict mode:
import{precompileTemplate}from'@ember/template-compilation';import{setComponentTemplate}from'@ember/component';importComponentfrom'@glimmer/component';import{action}from'@ember/object';import{on}from'@ember/modifier';exportdefaultsetComponentTemplate(precompileTemplate('<button {{on "click" this.alert}}>Go</button>',{strictMode: true,scope: { on },}),classextendsComponent{
@actionalert(){alert('it works');}});
results in a build error:
Scope objects for precompileTemplate may only contain direct references to in-scope values, e.g. { on } or { on: on }
The reason is that { on } is getting rewritten to { on: Ember._on}.
You can workaround like this:
import{precompileTemplate}from'@ember/template-compilation';import{setComponentTemplate}from'@ember/component';importComponentfrom'@glimmer/component';import{action}from'@ember/object';import{onashackOn}from'@ember/modifier';conston=hackOn;exportdefaultsetComponentTemplate(precompileTemplate('<button {{on "click" this.alert}}>Go</button>',{strictMode: true,scope: { on },}),classextendsComponent{
@actionalert(){alert('it works');}});
On Ember 3.25, strict mode is supported but babel-plugin-modules-api-polyfill is still needed. Under those conditions, trying to use any of the framework-provided helpers in strict mode:
results in a build error:
The reason is that
{ on }is getting rewritten to{ on: Ember._on}.You can workaround like this: