Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using handlebars helpers in a Custom Element raises error #554

Closed
dunnkers opened this issue Jun 17, 2017 · 1 comment
Closed

Using handlebars helpers in a Custom Element raises error #554

dunnkers opened this issue Jun 17, 2017 · 1 comment

Comments

@dunnkers
Copy link

Problem

A compilation error is thrown when a helper like {{action}} is used inside a custom element. e.g.

<paper-button raised {{action 'signIn'}}>Sign in</paper-button>

throws the following error:

Error: Compile Error: Element modifiers are not allowed in components

File: dummy/templates/index.hbs
The Broccoli Plugin: [broccoli-persistent-filter:TemplateCompiler] failed with:
Error: Compile Error: Element modifiers are not allowed in components
    at ComponentBlock.push (/Users/Dunnkers/Documents/git/ember-polymer/node_modules/ember-source/dist/ember-template-co
mpiler.js:481:27)
    at JavaScriptCompiler.push (/Users/Dunnkers/Documents/git/ember-polymer/node_modules/ember-source/dist/ember-templat
e-compiler.js:750:33)
    at JavaScriptCompiler.modifier (/Users/Dunnkers/Documents/git/ember-polymer/node_modules/ember-source/dist/ember-tem
plate-compiler.js:594:18)
    at /Users/Dunnkers/Documents/git/ember-polymer/node_modules/ember-source/dist/ember-template-compiler.js:549:31
    at Array.forEach (native)
    at JavaScriptCompiler.process (/Users/Dunnkers/Documents/git/ember-polymer/node_modules/ember-source/dist/ember-temp
late-compiler.js:541:26)
    at Function.process (/Users/Dunnkers/Documents/git/ember-polymer/node_modules/ember-source/dist/ember-template-compi
ler.js:535:29)
    at Function.compile (/Users/Dunnkers/Documents/git/ember-polymer/node_modules/ember-source/dist/ember-template-compi
ler.js:784:39)
    at precompile (/Users/Dunnkers/Documents/git/ember-polymer/node_modules/ember-source/dist/ember-template-compiler.js
:1292:58)
    at Object.precompile (/Users/Dunnkers/Documents/git/ember-polymer/node_modules/ember-source/dist/ember-template-comp
iler.js:15386:12)

The broccoli plugin was instantiated at:
    at TemplateCompiler.Plugin (/Users/Dunnkers/Documents/git/ember-polymer/node_modules/broccoli-plugin/index.js:7:31)
    at TemplateCompiler.Filter [as constructor] (/Users/Dunnkers/Documents/git/ember-polymer/node_modules/broccoli-persi
stent-filter/index.js:62:10)
    at TemplateCompiler (/Users/Dunnkers/Documents/git/ember-polymer/node_modules/ember-cli-htmlbars/index.js:18:5)
    at Object.toTree (/Users/Dunnkers/Documents/git/ember-polymer/node_modules/ember-cli-htmlbars/ember-addon-main.js:23
:16)
    at /Users/Dunnkers/Documents/git/ember-polymer/node_modules/ember-cli-preprocess-registry/preprocessors.js:180:26
    at Array.forEach (native)
    at processPlugins (/Users/Dunnkers/Documents/git/ember-polymer/node_modules/ember-cli-preprocess-registry/preprocess
ors.js:178:11)
    at module.exports.preprocessTemplates (/Users/Dunnkers/Documents/git/ember-polymer/node_modules/ember-cli-preprocess
-registry/preprocessors.js:161:10)
    at EmberAddon._processedTemplatesTree (/Users/Dunnkers/Documents/git/ember-polymer/node_modules/ember-cli/lib/brocco
li/ember-app.js:881:50)
    at EmberAddon.appAndDependencies (/Users/Dunnkers/Documents/git/ember-polymer/node_modules/ember-cli/lib/broccoli/em
ber-app.js:1099:26)


→ See dunnkers/ember-polymer#65

Cause

The error is thrown at javascript-compiler.ts#L91. Accompanying test: ember-component-test.ts#L2474.

Reproduction:

http://jsbin.com/cuyatamojo/edit?html,output

<some-custom-button-element {{action "some-action"}}>
  Do some cool action!
</some-custom-button-element>
@locks
Copy link
Contributor

locks commented Jun 22, 2017

You need to explicitly bind the onclick event like so: onclick={{action "some-action"}}.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants