summaryrefslogtreecommitdiff
path: root/addons/web/static/lib
diff options
context:
space:
mode:
authorXavier Morel <xmo@openerp.com>2012-01-24 11:11:55 +0100
committerXavier Morel <xmo@openerp.com>2012-01-24 11:11:55 +0100
commit4bfd2047aa86dabdfe7345ef77904f712a1e9dd5 (patch)
treeffccfb3e09c2dda6013bc5487e66136e6b67e128 /addons/web/static/lib
parentaebe04d321df9d49a2e0ba27cd49eb212559379f (diff)
parentaff08256261e72a516a20fc86d62f9c7c3f4085d (diff)
[FIX] template rendering issues in IE8
bzr revid: xmo@openerp.com-20120124101155-b52f8b3jd6otn7j9
Diffstat (limited to 'addons/web/static/lib')
-rw-r--r--addons/web/static/lib/qweb/qweb-test-extend.xml4
-rw-r--r--addons/web/static/lib/qweb/qweb-test-foreach.xml2
-rw-r--r--addons/web/static/lib/qweb/qweb-test.js.html11
-rw-r--r--addons/web/static/lib/qweb/qweb2.js55
4 files changed, 46 insertions, 26 deletions
diff --git a/addons/web/static/lib/qweb/qweb-test-extend.xml b/addons/web/static/lib/qweb/qweb-test-extend.xml
index 44fda920e43..35181eb8ee9 100644
--- a/addons/web/static/lib/qweb/qweb-test-extend.xml
+++ b/addons/web/static/lib/qweb/qweb-test-extend.xml
@@ -22,11 +22,11 @@
<t t-jquery="hr:eq(1)" t-operation="replace"><footer></footer></t>
</t>
<t t-extend="jquery-extend">
- <t t-jquery="footer" t-operation="inner"><b>END</b></t>
+ <t t-jquery="footer" t-operation="inner"><b>[[end]]</b></t>
</t>
<t t-name="jquery-extend-clone" t-extend="jquery-extend">
- <t t-jquery="ul" t-operation="append"><li>CLONED TEMPLATE</li></t>
+ <t t-jquery="ul" t-operation="append"><li>[[cloned template]]</li></t>
</t>
</templates>
diff --git a/addons/web/static/lib/qweb/qweb-test-foreach.xml b/addons/web/static/lib/qweb/qweb-test-foreach.xml
index 80749882aaf..8e335614c39 100644
--- a/addons/web/static/lib/qweb/qweb-test-foreach.xml
+++ b/addons/web/static/lib/qweb/qweb-test-foreach.xml
@@ -1,4 +1,4 @@
-<templates>
+<templates xml:space="preserve">
<t t-name="repetition-text-content" t-foreach="seq">*</t>
<t t-name="repetition-dom-content" t-foreach="seq"><b/></t>
<b t-name="repetition-self" t-foreach="seq"/>
diff --git a/addons/web/static/lib/qweb/qweb-test.js.html b/addons/web/static/lib/qweb/qweb-test.js.html
index fda837497c4..02ec89c134c 100644
--- a/addons/web/static/lib/qweb/qweb-test.js.html
+++ b/addons/web/static/lib/qweb/qweb-test.js.html
@@ -5,7 +5,6 @@
<link rel="stylesheet" href="http://code.jquery.com/qunit/git/qunit.css" type="text/css" media="screen"/>
<script type="text/javascript" src="http://code.jquery.com/qunit/git/qunit.js"></script>
- <script type="text/javascript" src="/base/static/lib/jquery/jquery-1.5.2.js"></script>
<script type="text/javascript" src="qweb2.js"></script>
<script>
@@ -14,7 +13,7 @@
return s.replace(/(^\s+|\s+$)/g, '');
}
function render(template, context) {
- return trim(QWeb.render(template, context));
+ return trim(QWeb.render(template, context)).toLowerCase();
}
$(document).ready(function() {
module("Basic output tests", {
@@ -209,9 +208,9 @@
test('Basic foreach repetition', function () {
equals(QWeb.render('repetition-text-content', {seq:seq}), '*****',
"Repetition of text content via foreach");
- equals(QWeb.render('repetition-dom-content', {seq:seq}), '<b/><b/><b/><b/><b/>',
+ equals(QWeb.render('repetition-dom-content', {seq:seq}).toLowerCase(), '<b/><b/><b/><b/><b/>',
"Repetition of node content via foreach");
- equals(QWeb.render('repetition-self', {seq:seq}), '<b/><b/><b/><b/><b/>',
+ equals(QWeb.render('repetition-self', {seq:seq}).toLowerCase(), '<b/><b/><b/><b/><b/>',
"A node with a foreach repeats itself");
});
test("Foreach scope content", function () {
@@ -249,9 +248,9 @@
});
test("jQuery extend", function () {
- equals(render('jquery-extend', {}), '<hr/><ul class="main"><li>1</li><li>2</li><li>3</li></ul><footer><b>END</b></footer>',
+ equals(render('jquery-extend', {}), '<hr/><ul class="main"><li>1</li><li>2</li><li>3</li></ul><footer><b>[[end]]</b></footer>',
"Extend template with jQuery");
- equals(render('jquery-extend-clone', {}), '<ul><li>one</li><li>CLONED TEMPLATE</li></ul>',
+ equals(render('jquery-extend-clone', {}), '<ul><li>one</li><li>[[cloned template]]</li></ul>',
"Clone template");
});
});
diff --git a/addons/web/static/lib/qweb/qweb2.js b/addons/web/static/lib/qweb/qweb2.js
index 8657a8b20be..089b1812aa5 100644
--- a/addons/web/static/lib/qweb/qweb2.js
+++ b/addons/web/static/lib/qweb/qweb2.js
@@ -93,10 +93,16 @@ var QWeb2 = {
}
return r.join('');
} else {
- if (node.xml !== undefined) {
- return node.xml;
- } else {
+ if (typeof XMLSerializer !== 'undefined') {
return (new XMLSerializer()).serializeToString(node);
+ } else {
+ switch(node.nodeType) {
+ case 1: return node.outerHTML;
+ case 3: return node.data;
+ case 4: return '<![CDATA[' + node.data + ']]>';
+ case 8: return '<!-- ' + node.data + '-->';
+ }
+ throw new Error('Unknown node type ' + node.nodeType);
}
}
},
@@ -265,11 +271,16 @@ QWeb2.Engine = (function() {
}
req.open('GET', s, false);
req.send(null);
- if (req.responseXML) {
- if (req.responseXML.documentElement.nodeName == "parsererror") {
- return this.tools.exception(req.responseXML.documentElement.childNodes[0].nodeValue);
+ var xDoc = req.responseXML;
+ if (xDoc) {
+ if (xDoc.documentElement.nodeName == "parsererror") {
+ return this.tools.exception(xDoc.documentElement.childNodes[0].nodeValue);
}
- return req.responseXML;
+ if (xDoc.xml !== undefined) {
+ // MSIE
+ return this.convert_xml_to_html(xDoc.documentElement);
+ }
+ return xDoc;
} else {
return this.load_xml_string(req.responseText);
}
@@ -295,7 +306,25 @@ QWeb2.Engine = (function() {
xDoc.async = false;
xDoc.preserveWhiteSpace = true;
xDoc.loadXML(s);
- return xDoc;
+ return this.convert_xml_to_html(xDoc.documentElement);
+ },
+ convert_xml_to_html: function (node) {
+ switch (node.nodeType) {
+ case 3:
+ case 4:
+ return document.createTextNode(node.data);
+ case 8: return document.createComment(node.data);
+ }
+
+ var hnode = document.createElement(node.nodeName);
+ for(var i=0, alen=node.attributes.length; i < alen; ++i) {
+ var attr = node.attributes[i];
+ hnode.setAttribute(attr.name, attr.value);
+ }
+ for(var j=0, clen=node.childNodes.length; j < clen; ++j) {
+ hnode.appendChild(this.convert_xml_to_html(node.childNodes[j]));
+ }
+ return hnode;
},
has_template : function(template) {
return !!this.templates[template];
@@ -373,12 +402,7 @@ QWeb2.Engine = (function() {
if (!this.jQuery) {
return this.tools.exception("Can't extend template " + template + " without jQuery");
}
- var template_dest = this.templates[template],
- msie_trololo = false;
- if (template_dest.xml !== undefined) {
- template_dest = this.jQuery(template_dest.xml);
- msie_trololo = true;
- }
+ var template_dest = this.templates[template];
for (var i = 0, ilen = extend_node.childNodes.length; i < ilen; i++) {
var child = extend_node.childNodes[i];
if (child.nodeType === 1) {
@@ -421,9 +445,6 @@ QWeb2.Engine = (function() {
}
}
}
- if (msie_trololo) {
- this.templates[template] = template_dest[0];
- }
}
});
return Engine;