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

Block params named component are unusable in 2.9 beta #14413

Closed
Panman82 opened this issue Oct 4, 2016 · 4 comments
Closed

Block params named component are unusable in 2.9 beta #14413

Panman82 opened this issue Oct 4, 2016 · 4 comments
Labels
Milestone

Comments

@Panman82
Copy link
Contributor

Panman82 commented Oct 4, 2016

Starting this per @rwjblue request. While I can understand why this wouldn't necessarily work.

When naming a block param component, it's not really usable within the block scope. This did work for me <= 2.7. I've just refactored away from the name but just reporting it here... Couple issues I noticed;

  • Nothing is output when using it as text <li>{{component}}</li>
  • An error is produced when used as an attribute. <li data-value="{{component}}">Foobar</li>
    • Uncaught Error: Assertion Failed: You cannot create a component from undefined using the {{component}} helper
<h4>each as |abc|</h4>
<ul>
  {{#each components as |abc|}}
    <li>{{abc}}</li>
  {{/each}}
</ul>
<h4>each as |component|</h4>
<ul>
  {{#each components as |component|}}
    <li>{{component}}</li>
  {{/each}}
</ul>
<h4>each as |component| <em>in attribute</em></h4>
<ul>
  {{#each components as |component index|}}
    <li data-value="{{component}}">{{index}}</li>
  {{/each}}
</ul>

Reproduced the issue in ember-twiddle: https://ember-twiddle.com/24f1983de422ed7039c5b21af68cc032?fileTreeShown=false&numColumns=2&openFiles=controllers.application.js%2Ctemplates.application.hbs

@Serabe
Copy link
Member

Serabe commented Oct 5, 2016

I would not consider this a bug but the previous behaviour. {{component}} and (component) are keywords in 2.8 (not sure there is a different term for them in >2.9) and that meant they were low-level helpers.

Helpers in 2.7 took precedence over properties with the same name (see this twiddle), so I guess that this change of behaviour just make it standard.

I think I have seen a test regarding helper precedence, but cannot find it now.

@rwjblue
Copy link
Member

rwjblue commented Oct 5, 2016

Yeah, helpers and keywords will win over properties, but they shouldn't win over block params. Block params should always win...

@Serabe
Copy link
Member

Serabe commented Oct 5, 2016

@rwjblue: I updated the twiddle to show that the behaviour is consistent with block params as well: helpers win (the twiddle is using 2.7).

I think this is consistent behaviour non making a difference between a block param and a property. Otherwise, refactoring a block to a component would be harder than one would expect.

@chancancode chancancode modified the milestone: 2.10.0 Oct 17, 2016
tilde-engineering pushed a commit to tildeio/ember.js that referenced this issue Oct 26, 2016
This pulls in two glimmer-engine bugfixes:

- local variables (block params) should always win over helpers
- stateful/class-based helpers used in `{{#if (my-helper ...)}}` and
  other block arguments position are destroyed when the block syntax
  switches from default to inverse (and vice versa)

Fixes emberjs#14351, emberjs#14413
tilde-engineering pushed a commit to tildeio/ember.js that referenced this issue Oct 26, 2016
This pulls in two glimmer-engine bugfixes:

- local variables (block params) should always win over helpers
- stateful/class-based helpers used in `{{#if (my-helper ...)}}` and
  other block arguments position are destroyed when the block syntax
  switches from default to inverse (and vice versa)

Fixes emberjs#14351, emberjs#14413
chancancode added a commit that referenced this issue Oct 26, 2016
This pulls in two glimmer-engine bugfixes:

- local variables (block params) should always win over helpers
- stateful/class-based helpers used in `{{#if (my-helper ...)}}` and
  other block arguments position are destroyed when the block syntax
  switches from default to inverse (and vice versa)

Fixes #14351, #14413

(cherry picked from commit 8c87e50)
@chancancode
Copy link
Member

It seems like #14520 didn't fix this particular scenario – what I did was to make block params always win over helpers on the Glimmer side. However, since {{component ...}} is handled by Ember in here, we need another fix/test for this case.

wycats pushed a commit that referenced this issue Nov 9, 2016
...and `input`, `outlet`, etc. Block params (local variables) should
always win over helpers and built-in syntaxes.

Fixes #14413
chancancode added a commit that referenced this issue Nov 9, 2016
...and `input`, `outlet`, etc. Block params (local variables) should
always win over helpers and built-in syntaxes.

Fixes #14413
chancancode added a commit that referenced this issue Nov 9, 2016
...and `input`, `outlet`, etc. Block params (local variables) should
always win over helpers and built-in syntaxes.

Fixes #14413
chancancode added a commit that referenced this issue Nov 27, 2016
...and `input`, `outlet`, etc. Block params (local variables) should
always win over helpers and built-in syntaxes.

Fixes #14413

(cherry picked from commit 38f3172)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants