lazd / DOMly

The fast template system that creates and clones DOM nodes
MIT License
53 stars 9 forks source link

Reset data after foreach loop #23

Closed georgkoester closed 9 years ago

georgkoester commented 9 years ago

After a loop completes, the data variable is still set to the loop's data context.

When accessing the data variable inside of a <js> block, we'll end up with the outside context set to the inside context when the <js> block ends.

lazd commented 9 years ago

@georgkoester just to follow up, since data is referenced by name (instead of data_0 etc) in <js> eval blocks only, it made sense to reset the assignment before the eval'd code instead of after the for loop. This avoids extra, unnecessary data = data_0 statements in the compiled output. I went ahead and made this change and added additional tests for data context in nested for loops.

Great catch, I'm glad we got this one fixed!