[FIX] Do not self close empty elements that are not html void elements

bzr revid: fme@openerp.com-20140507121413-o7jqhexbm1wmitt6
This commit is contained in:
Fabien Meghazi 2014-05-07 14:14:13 +02:00
parent 7db3619c37
commit 4373f85773
3 changed files with 10 additions and 5 deletions

View File

@ -29,7 +29,7 @@
<div t-if="testing || true" t-att-class="novar || 'yes'" style="display: none">
<t t-set="novar"></t>
<t t-set="style">height: 200px; border: 1px solid red;</t>
<div t-att="{ 'style' : style, 'disabled' : 'false', 'readonly' : novar or undefined }" t-opentag="true"/>
<div t-att="{ 'style' : style, 'disabled' : 'false', 'readonly' : novar or undefined }"/>
<t t-foreach="{'my': 'first', 'my2': 'second' }" t-as="v">
* <t t-esc="v"/> : <t t-esc="v_value"/>
</t>

View File

@ -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("/>");
}
}
},

View File

@ -496,7 +496,7 @@
</h2>
</td>
<td colspan="2">
<div class="oe_view_manager_view_search" t-opentag="true"/>
<div class="oe_view_manager_view_search"/>
</td>
</tr>
<tr class="oe_header_row">