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

Add failing test for empty-nest case #70

Merged
merged 1 commit into from Jul 16, 2016

Conversation

rschick
Copy link
Contributor

@rschick rschick commented Jul 15, 2016

Hi,

I was hoping you could help fix this test case. I'm pretty sure it should pass.

First test passes, 2nd one with the empty nested foreach fails.

I've spent some time trying to figure out how to fix it, but couldn't find a fix.

Thanks,
Russ

@shepherdwind
Copy link
Owner

ok, thanks for you test case, I will fix it soon

@shepherdwind shepherdwind merged commit 515d029 into shepherdwind:master Jul 16, 2016
@shepherdwind
Copy link
Owner

shepherdwind commented Jul 16, 2016

I fix it now, 0.8.5 published.

This bug fixed by do this commit 821b506#diff-a509cb5a1016a02a707bb7b706e93c5cR222 .

When foreach loop start, I will create a local contextId, and push it to this.condictions at this._render. _render will render asts tree with an new context local. when variable lookup, will from the top condition item first.

// code at  blocks.js getBlockEach 
        this.local[contextId] = local;
        ret += this._render(_block, contextId);

// code as refefences.js getLocal
      utils.some(this.conditions, function(contextId) {
        var _local = local[contextId];
        if (id in _local) {
          ret = _local[id];
          return true;
        }

        return false;
      }, this);

But, when empty foreach , _render do not run, and after the clear context is already run. So render this inner foreach, will empty the parent context, and $foreach.hasNext return to null.

@rschick
Copy link
Contributor Author

rschick commented Jul 16, 2016

Thanks very much!

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.

None yet

2 participants