From ec9ae7ec813999f721136f8006c5028e376b37da Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Thu, 25 Jul 2013 13:30:41 +0200 Subject: [PATCH] Does not allow functions in loops anymore bzr revid: nicolas.vanhoren@openerp.com-20130725113041-n6u9gyo1vbv1blw5 --- addons/web/Gruntfile.js | 1 - addons/web/static/src/js/corelib.js | 8 ++++---- addons/web/static/src/js/view_list.js | 15 ++++++++------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/addons/web/Gruntfile.js b/addons/web/Gruntfile.js index d1e897d8e20..e821504c4d1 100644 --- a/addons/web/Gruntfile.js +++ b/addons/web/Gruntfile.js @@ -7,7 +7,6 @@ module.exports = function(grunt) { sub: true, //[] instead of . evil: true, //eval laxbreak: true, //unsafe line breaks - loopfunc: true, // functions in loops }, } }); diff --git a/addons/web/static/src/js/corelib.js b/addons/web/static/src/js/corelib.js index 07874f763af..6ab7a30c642 100644 --- a/addons/web/static/src/js/corelib.js +++ b/addons/web/static/src/js/corelib.js @@ -96,7 +96,7 @@ openerp.web.corelib = function(instance) { initializing = false; // Copy the properties over onto the new prototype - for (var name in prop) { + _.each(prop, function(val, name) { // Check if we're overwriting an existing function prototype[name] = typeof prop[name] == "function" && fnTest.test(prop[name]) ? @@ -117,7 +117,7 @@ openerp.web.corelib = function(instance) { }; })(name, prop[name]) : prop[name]; - } + }); // The dummy class constructor function Class() { @@ -132,7 +132,7 @@ openerp.web.corelib = function(instance) { return this; } Class.include = function (properties) { - for (var name in properties) { + _.each(properties, function(val, name) { if (typeof properties[name] !== 'function' || !fnTest.test(properties[name])) { prototype[name] = properties[name]; @@ -158,7 +158,7 @@ openerp.web.corelib = function(instance) { }; })(name, properties[name]); } - } + }); }; // Populate our constructed prototype object diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index 3e34a895321..75c8f3c7e84 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -1519,6 +1519,13 @@ instance.web.ListView.Groups = instance.web.Class.extend( /** @lends instance.we // if drag to 1st row (to = 0), start sequencing from 0 // (exclusive lower bound) seq = to ? list.records.at(to - 1).get(seqname) : 0; + var fct = function (dataset, id, seq) { + $.async_when().done(function () { + var attrs = {}; + attrs[seqname] = seq; + dataset.write(id, attrs); + }); + }; while (++seq, (record = list.records.at(index++))) { // write are independent from one another, so we can just // launch them all at the same time and we don't really @@ -1526,13 +1533,7 @@ instance.web.ListView.Groups = instance.web.Class.extend( /** @lends instance.we // FIXME: breaks on o2ms (e.g. Accounting > Financial // Accounting > Taxes > Taxes, child tax accounts) // when synchronous (without setTimeout) - (function (dataset, id, seq) { - $.async_when().done(function () { - var attrs = {}; - attrs[seqname] = seq; - dataset.write(id, attrs); - }); - }(dataset, record.get('id'), seq)); + fct(dataset, record.get('id'), seq); record.set(seqname, seq); } }