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

Closure actions cannot be used as event handlers in Safari #11604

Closed
xtian opened this issue Jun 30, 2015 · 4 comments
Closed

Closure actions cannot be used as event handlers in Safari #11604

xtian opened this issue Jun 30, 2015 · 4 comments

Comments

@xtian
Copy link
Contributor

xtian commented Jun 30, 2015

In Chrome, the new 1.13 closure actions can be used as event handlers directly on an element, but they throw an exception in Safari:

<div onclick={{action "click"}}></div>

// Clicking on the <div> in Safari throws:
// => SyntaxError: Function statements must have a name. (line 1)

Not sure if this officially supported functionality, though. Here are some JSBins:

1.13:
http://emberjs.jsbin.com/hamixovace/1/edit?html,js,console,output

Canary:
http://emberjs.jsbin.com/hamixovace/2/edit?html,js,console,output

@mixonic
Copy link
Member

mixonic commented Jun 30, 2015

@xtian this behavior is emergent, and not really an intended API. We would like to introduce something we've called "kabob" event listeners in the near term. They would look like:

<div on-click={{action "save"}}></div>

This needs an RFC and implementation though.

For your immediate case, I suggest using a combination of the element space action helper and the closure action. For example:

<div {{action (action "save") on="click"}}></div>

Or alternatively (the behavior is slightly different, but similar) just keep using element actions:

<div {{action "save" on="click"}}></div>

@mixonic mixonic closed this as completed Jun 30, 2015
@xtian
Copy link
Contributor Author

xtian commented Jun 30, 2015

Ok, good to know!

@stefanpenner
Copy link
Member

I believe tildeio/htmlbars#374 fixes this issue.

@stefanpenner
Copy link
Member

1.13.3 should fix this since tildeio/htmlbars#374 has been merged

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

3 participants