BorisMoore / jsviews

Interactive data-driven views, MVVM and MVP, built on top of JsRender templates
http://www.jsviews.com/#jsviews
MIT License
855 stars 130 forks source link

Infinite loop bug, when using recursive templates + variables + data-link #351

Closed artemipanchuk closed 7 years ago

artemipanchuk commented 7 years ago

Look at following fiddle: https://jsfiddle.net/nm3zw58b/6/. In this fiddle, I am using simplified type of recursive template, used by my tree tag in my project. Template calls itself by using for expression, passing new values of ~level and ~depth . So, there is if expression:

{{if ~level !== 0}}
  <div class="tree-relative-container">
    {{:value}}
  </div>
{{/if}}

With this if expression everything works ok. But sometimes I need to pass more sophisticated conditions and expressions, in my case --- with data-link.

So there is a bit modified version of my fiddle: https://jsfiddle.net/nm3zw58b/7/. The only difference is: {^{if ~level !== 0}}.

With this change everything goes into infinite loop.

BorisMoore commented 7 years ago

Thanks for calling this out. Yes, that is a bug. The issue arises when you have a recursive contextual parameter expression, as you do in your template: ~level=~level+1

A simpler repro for the bug is this:

{{include ~level=~level}}
    {^{:~level1}}
{{/include}}

I am investigating fixes - I'll let you know...

BorisMoore commented 7 years ago

This has been fixed in commit v0.9.83