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

behave like can-stache-element to create a renderer from passed view #372

Merged
merged 4 commits into from
Jul 19, 2022

Conversation

pYr0x
Copy link

@pYr0x pYr0x commented Jul 9, 2022

this PR changes the behavior for creating a renderer.
in can-stache-element link checks if the view is a function (renderer function).
can-component behaved different. it checked for view beeing a string.
https://github.com/canjs/can-component/blob/master/can-component.js#L383-L385

this is a breaking change, but the current documentation is still correct. so maybe this isn't worth to create a major release.
https://canjs.com/doc/can-component.prototype.view.html

this close #371

can-component.js Outdated
var viewName = string.capitalize( string.camelize(this.prototype.tag) )+"View";
this.view = stache(viewName, this.view);

var viewName = string.capitalize( string.camelize(this.prototype.tag) )+"View";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like you're moving a var-type variable declaration out of a block, which is good, but I think we should still keep the computation of the viewName in the if block. Like this:

var viewName;
if (/* ... */) {
 viewName = string.capitalize(string.camelize(this.prototype.tag) ) + "View";
 // ...
}

@bmomberger-bitovi bmomberger-bitovi merged commit afaca31 into master Jul 19, 2022
@bmomberger-bitovi bmomberger-bitovi deleted the can-stache-element-compat branch July 19, 2022 16:01
pYr0x pushed a commit that referenced this pull request Jul 21, 2022
bmomberger-bitovi added a commit that referenced this pull request Feb 20, 2023
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

Successfully merging this pull request may close these issues.

behave like can-stache-element for passing a view
2 participants