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

ember-radio-button addon not working with 1.13 betas (includes jsbins) #11301

Closed
raycohen opened this issue May 28, 2015 · 18 comments
Closed

ember-radio-button addon not working with 1.13 betas (includes jsbins) #11301

raycohen opened this issue May 28, 2015 · 18 comments
Milestone

Comments

@raycohen
Copy link
Contributor

this came up trying to get the ember-radio-button addon working with the ember 1.13 betas.

I am using if (this.get('template')) to detect if the component is being used with a block. This is no longer working.

Some jsbins that help demonstrate the behavior change:

working in ember 1.12:
http://emberjs.jsbin.com/zihixaqaxo/2/edit?html,css,js,output

not working in beta:
http://emberjs.jsbin.com/zihixaqaxo/3/edit?html,css,js,output

@OrKoN
Copy link

OrKoN commented May 28, 2015

@raycohen I think you should use hasBlock to check if there is a block http://emberjs.com/api/classes/Ember.Component.html#property_hasBlock

template seems to be deprecated. http://emberjs.com/api/classes/Ember.Component.html#property_template

@raycohen
Copy link
Contributor Author

@OrKoN hasBlock is not working for me either. Substituting it for template in my jsbins has no effect

@raycohen raycohen changed the title Is there a supported way to detect if a component is being used with a block? ember-radio-button addon not working with 1.13 betas (includes jsbins) May 28, 2015
@OrKoN
Copy link

OrKoN commented May 28, 2015

@raycohen I have only used it in the template like this: http://emberjs.jsbin.com/kixiteqiba/1/edit?html,css,js,output

It looks like it's only available within templates...

@rwjblue
Copy link
Member

rwjblue commented May 29, 2015

you cannot use hasBlock in JS code. It is available only in template-land.

@raycohen
Copy link
Contributor Author

ok. so there's no way to do what I was doing in 1.12 in 1.13+?

@rwjblue
Copy link
Member

rwjblue commented May 30, 2015

In general, I think I would advise using the hasBlock helper to render one or the other component that you ultimately intend to render via the template instead of changing the layout/attributeBindings on demand.

@rwjblue
Copy link
Member

rwjblue commented May 30, 2015

However, I definitely consider it a regression that if (this.get('template')) used to work to detect if your component was invoked in block form and now it doesn't. I trying to work out a fix with deprecation for that...

@rwjblue
Copy link
Member

rwjblue commented May 31, 2015

Also related to #11186.

@rwjblue
Copy link
Member

rwjblue commented Jun 1, 2015

I submitted #11313 to allow usage of this.get('template') to determine if a block was provided, and #11186 as a failing test for rerendering when layout changes.

@SirZach
Copy link

SirZach commented Jun 3, 2015

as of 13-beta.1, the actual implementation for hasBlock has been removed. The docs are still there but the property definition is gone. https://github.com/emberjs/ember.js/blob/v1.13.0-beta.2/packages/ember-views/lib/views/component.js do a find for hasBlock: and you'll see it's gone.

@mmun
Copy link
Member

mmun commented Jun 3, 2015

@SirZach It's implemented in the template. See ember-htmlbars/lib/hooks/get-root. It was never implemented in the component's class.

@SirZach
Copy link

SirZach commented Jun 3, 2015

@mmun https://github.com/emberjs/ember.js/blob/v1.12.1/packages/ember-views/lib/views/component.js it's implemented in the class there. Nice find and thanks. With the newer implementation approach, is there any way to get a hold of hasBlock in the component's JS code?

@mmun
Copy link
Member

mmun commented Jun 3, 2015

@SirZach Oops, you're right. There isn't a way to get it right now. And I'm fairly convinced you shouldn't need this though. Can your use case be accomplished within the template? If not, can you explain it? It would be helpful for me.

@SirZach
Copy link

SirZach commented Jun 3, 2015

My use case is for backwards compatibility. In pre 13, I could check for template to know if the component was being used in block form. In 13 and later, I have to use hasBlock. In order to have components that could work in block form with glimmer and non-glimmer apps, I was going to have a computed property on the component that would check these two properties.

@mmun
Copy link
Member

mmun commented Jun 3, 2015

@SirZach Yeah. We're planning on making template a boolean so that it's mostly backwards compatible with how people were using it. It will fire deprecation warnings on consumption. It is definitely a semver violation to have broken that. But in terms of adding a new API to the Component JS, hasBlock, I'm not convinced we need to.

@rwjblue
Copy link
Member

rwjblue commented Jun 3, 2015

#11313 makes template a boolean, and is pending review.

@SirZach
Copy link

SirZach commented Jun 3, 2015

Thanks @rwjblue ! Sorry I realize now that's what you were talking about in this thread. Thanks @mmun for the quick replies!

@btecu
Copy link
Contributor

btecu commented Jul 28, 2015

I think this can be closed.

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

6 participants