From adbf2dad81519c35f268cab14197cd8c765231e9 Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Wed, 4 May 2016 11:17:56 +0100 Subject: [PATCH] ArrayEditable: replace self.$items When shrinking the number of items, this allows the old elements to be GCed sooner. --- source/UI/js/Form/ArrayEditable.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/UI/js/Form/ArrayEditable.js b/source/UI/js/Form/ArrayEditable.js index 0e583ae4..ec9a9c5f 100644 --- a/source/UI/js/Form/ArrayEditable.js +++ b/source/UI/js/Form/ArrayEditable.js @@ -142,23 +142,23 @@ Ox.ArrayEditable = function(options, self) { } that.empty(); if (self.options.items.length == 0) { - self.$items[0] = Ox.Editable({ + self.$items = [Ox.Editable({ editable: false, placeholder: self.options.placeholder, type: self.options.type, value: '' }) - .appendTo(that); + .appendTo(that)]; } else { sortItems(); - self.options.items.forEach(function(item, i) { + self.$items = self.options.items.map(function appendItem(item, i) { if (i && self.options.type == 'input') { $('') .addClass('OxSeparator') .html(self.options.separator + ' ') .appendTo(that); } - self.$items[i] = Ox.Editable({ + return Ox.Editable({ autocomplete: self.options.autocomplete, autocompleteReplace: self.options.autocompleteReplace, autocompleteReplaceCorrect: self.options.autocompleteReplaceCorrect,