I just upgraded jQuery from 1.8.3 to 1.9, and it suddenly started crashing.
This is my template:
<script type="text/template" id="modal_template"> <div>hello</div> </script>
Here is how I read it:
modal_template_html = $("#modal_template").html();
This is how I convert it to a jQuery object (I need to use jQuery methods on it):
template = $(modal_template_html);
... and jQuery crashed!
Error: syntax error, unrecognized expression: <div> hello </div>
slice.call (docElem.childNodes, 0) [0] .nodeType;
jquery-1.9.0.js (line 3811)
However, if I declare the template as a text variable, it starts working again:
var modal_template_html = '<div>hello</div>';
Can someone help me figure this out?
UPDATE : The jquery team heard and changed things in normal mode in 1.10:
The biggest change you'll probably see is that weve relaxed the criteria for processing HTML in $ (), which allows you to use spaces and newlines, as it was before version 1.9
javascript jquery mustache
Evgeny Jan 15 '13 at 21:53 2013-01-15 21:53
source share