From 3be3c6f532fafff30c243d849e04e99547b4cad5 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Tue, 28 Feb 2017 12:20:36 +0100 Subject: [PATCH] [FIX] qweb2.js: fix erratic object type detection in foreach (Fixes #15655) Could not add a test as the qweb js testsuite is broken and it's xml test files have been modified in order to test qweb.py specific cases. --- addons/web/static/lib/qweb/qweb2.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/web/static/lib/qweb/qweb2.js b/addons/web/static/lib/qweb/qweb2.js index b1bf280f516..25c3ef94d1b 100644 --- a/addons/web/static/lib/qweb/qweb2.js +++ b/addons/web/static/lib/qweb/qweb2.js @@ -147,14 +147,15 @@ var QWeb2 = { foreach: function(context, enu, as, old_dict, callback) { if (enu != null) { var index, jlen, cur; - var size, new_dict = this.extend({}, old_dict); + var new_dict = this.extend({}, old_dict); new_dict[as + "_all"] = enu; var as_value = as + "_value", as_index = as + "_index", as_first = as + "_first", as_last = as + "_last", as_parity = as + "_parity"; - if (size = enu.length) { + if (enu instanceof Array) { + var size = enu.length; new_dict[as + "_size"] = size; for (index = 0, jlen = enu.length; index < jlen; index++) { cur = enu[index];