Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: runtime filescope was wrongly renitialized
The filescope injected by the compiler inside the template function was properly retrieved during initialization. But then, the variable being wrongly defined as a closure variable, it was reinitialized and not reassigned on subsequent calls.
- Loading branch information
Benoit Charbonnier
committed
Sep 1, 2014
1 parent
f95e5df
commit 1af5ebf
Showing
3 changed files
with
55 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
|
||
/* | ||
* Copyright 2012 Amadeus s.a.s. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
var hsp=require("hsp/rt"), | ||
ht=require("hsp/utils/hashtester"); | ||
|
||
|
||
function globalHelper() { | ||
return true; | ||
} | ||
|
||
{template test1} | ||
{if (globalHelper())} | ||
<div class="test">I am here because of a global helper</div> | ||
{/if} | ||
{/template} | ||
|
||
{template test2} | ||
<#test1 /> | ||
<#test1 /> | ||
{/template} | ||
|
||
describe("Templates using expressions with global references", function () { | ||
|
||
it("should actually access the reference", function () { | ||
var h = ht.newTestContext(); | ||
test1().render(h.container); | ||
expect(h.container.childNodes[1].innerHTML).to.equal("I am here because of a global helper"); | ||
h.$dispose(); | ||
}); | ||
|
||
it("should be rendered more than once w/ no error", function () { | ||
var h = ht.newTestContext(); | ||
test2().render(h.container); | ||
expect(h(".test").length).to.equal(2); | ||
h.$dispose(); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters