Closed zavulon closed 13 years ago
The only tmplItem that does not have a nodes property is the topTmplItem, which has key 0. The second condition should prevent entering the if block, in that case, since pntNode will be zero. Can you provide a test case in which that type error occurred?
Closing, since no reply to request for test case...
The below code gets "Uncaught TypeError: Cannot call method 'push' of undefined" jquery.tmpl.js:429 But once I replace 'a' element to span or div on #testTmpl then it works peacefully.
Chrome14/Firefox6.0
<body>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script src="https://raw.github.com/nanzhi/jquery-tmpl/master/jquery.tmpl.js"></script>
<script id="test2Tmpl" type="text/x-jquery-tmpl">
<div>
<a>test</a>
</div>
</script>
<script id="testTmpl" type="text/x-jquery-tmpl">
<a>
{{tmpl() "#test2Tmpl"}}
</a>
</script>
<script>
$(document).ready(function(){
$('#testTmpl').tmpl().appendTo('body');
});
</script>
</body>
I'm also having this issue. Removing "a" tag from subtemplate removes the error, but we need "a" tag in the subtemplate.
Line 426 should be relpaced from
while ( pntItem && pntItem.key != pntNode ) {
to
while ( pntItem.nodes && pntItem.key != pntNode ) {