diff --git a/addons/web/static/lib/qweb/qweb2.js b/addons/web/static/lib/qweb/qweb2.js
index 7d58b2492f7..076a658dce9 100644
--- a/addons/web/static/lib/qweb/qweb2.js
+++ b/addons/web/static/lib/qweb/qweb2.js
@@ -276,10 +276,6 @@ QWeb2.Engine = (function() {
if (xDoc.documentElement.nodeName == "parsererror") {
return this.tools.exception(xDoc.documentElement.childNodes[0].nodeValue);
}
- if (xDoc.xml !== undefined) {
- // MSIE
- return this.convert_xml_to_html(xDoc.documentElement);
- }
return xDoc;
} else {
return this.load_xml_string(req.responseText);
@@ -307,25 +303,7 @@ QWeb2.Engine = (function() {
xDoc.async = false;
xDoc.preserveWhiteSpace = true;
xDoc.loadXML(s);
- 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;
+ return xDoc;
},
has_template : function(template) {
return !!this.templates[template];
@@ -431,15 +409,15 @@ QWeb2.Engine = (function() {
this.tools.exception(error_msg + "Invalid operation : '" + operation + "'");
}
operation = {'replace' : 'replaceWith', 'inner' : 'html'}[operation] || operation;
- target[operation](this.jQuery(inner));
+ target[operation](child.cloneNode(true));
} else {
try {
- var f = new Function(['$'], inner);
+ var f = new Function(['$', 'document'], inner);
} catch(error) {
return this.tools.exception("Parse " + error_msg + error);
}
try {
- f.apply(target, [this.jQuery]);
+ f.apply(target, [this.jQuery, template_dest.ownerDocument]);
} catch(error) {
return this.tools.exception("Runtime " + error_msg + error);
}
diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml
index 550f930e3d1..8a8e39e0b7e 100644
--- a/addons/web/static/src/xml/base.xml
+++ b/addons/web/static/src/xml/base.xml
@@ -680,10 +680,9 @@