diff --git a/addons/web/static/lib/qweb/qweb-benchmark.xml b/addons/web/static/lib/qweb/qweb-benchmark.xml
index 71452572e51..8d1e913f3e2 100644
--- a/addons/web/static/lib/qweb/qweb-benchmark.xml
+++ b/addons/web/static/lib/qweb/qweb-benchmark.xml
@@ -29,7 +29,7 @@
height: 200px; border: 1px solid red;
-
+
* :
diff --git a/addons/web/static/lib/qweb/qweb2.js b/addons/web/static/lib/qweb/qweb2.js
index 0289af91a60..78e4fd8b544 100644
--- a/addons/web/static/lib/qweb/qweb2.js
+++ b/addons/web/static/lib/qweb/qweb2.js
@@ -37,6 +37,7 @@ var QWeb2 = {
'lt': '<',
'lte': '<='
},
+ VOID_ELEMENTS: 'area,base,br,col,embed,hr,img,input,keygen,link,menuitem,meta,param,source,track,wbr'.split(','),
tools: {
exception: function(message, context) {
context = context || {};
@@ -218,6 +219,7 @@ QWeb2.Engine = (function() {
this.jQuery = window.jQuery;
this.reserved_words = QWeb2.RESERVED_WORDS.slice(0);
this.actions_precedence = QWeb2.ACTIONS_PRECEDENCE.slice(0);
+ this.void_elements = QWeb2.VOID_ELEMENTS.slice(0);
this.word_replacement = QWeb2.tools.extend({}, QWeb2.WORD_REPLACEMENT);
this.preprocess_node = null;
for (var i = 0; i < arguments.length; i++) {
@@ -480,6 +482,7 @@ QWeb2.Element = (function() {
this._bottom = [];
this._indent = 1;
this.process_children = true;
+ this.is_void_element = ~QWeb2.tools.arrayIndexOf(this.engine.void_elements, this.tag);
var childs = this.node.childNodes;
if (childs) {
for (var i = 0, ilen = childs.length; i < ilen; i++) {
@@ -677,11 +680,13 @@ QWeb2.Element = (function() {
this.top("r.push(context.engine.tools.gen_attribute(['" + m[1] + "', (" + (this.string_interpolation(v)) + ")]));");
}
}
- if (this.children.length || this.actions.opentag === 'true') {
+ if (this.actions.opentag === 'true' || (!this.children.length && this.is_void_element)) {
+ // We do not enforce empty content on void elements
+ // because QWeb rendering is not necessarily html.
+ this.top_string("/>");
+ } else {
this.top_string(">");
this.bottom_string("" + this.tag + ">");
- } else {
- this.top_string("/>");
}
}
},
diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml
index 18a55656df2..75d4bdbb1c6 100644
--- a/addons/web/static/src/xml/base.xml
+++ b/addons/web/static/src/xml/base.xml
@@ -496,7 +496,7 @@
-
+
|