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

can.stache is returning incorrect values for DOM attributes #1065

Closed
alexisabril opened this issue Jun 10, 2014 · 4 comments · Fixed by #1083
Closed

can.stache is returning incorrect values for DOM attributes #1065

alexisabril opened this issue Jun 10, 2014 · 4 comments · Fixed by #1083
Milestone

Comments

@alexisabril
Copy link
Contributor

Truthy statements such as: {{#foo}}bar{{/foo}} are correctly calculated, except when within a DOM element's attribute(such as class). In that case, only the last .fn() or .inverse() is returned.

http://jsfiddle.net/f2Zwm/1/

@daffl daffl added this to the 2.1.2 milestone Jun 11, 2014
@robregonm
Copy link

I think this issue could be related to #1063

@alexisabril
Copy link
Contributor Author

@robregonm Yes, these do appear to be the same issue. This is true of all DOM attributes it seems as well, not just class. We've marked this for 2.1.2, so we'll have a fix asap.

@daffl
Copy link
Contributor

daffl commented Jun 11, 2014

Are you sure those are related? #1063 is in Mustache and this appears only in Stache.

@daffl
Copy link
Contributor

daffl commented Jun 12, 2014

This bug already causes simple things like

<h2 class="{{#if shown}}foo{{/if}} test1 {{#shown}}muh{{/shown}}"></h2>
<h3 class="{{#if shown}}bar{{/if}} test2 {{#shown}}kuh{{/shown}}"></h3>
<h4 class="{{#if shown}}baz{{/if}} test3 {{#shown}}boom{{/shown}}"></h4>

To fail, filling in the wrong subsections due to evaluator caching in https://github.com/bitovi/canjs/blob/master/view/stache/mustache_core.js#L419 (as pointed out in the Todo the line before).

I recommend removing the caching - unless @justinbmeyer has another idea - since subsections are almost always different (except for the visual benchmark). It will slow the visual benchmark performance down from ~3.9ms to ~7.6ms.

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 a pull request may close this issue.

3 participants