From befb13dde11cebf339b7d8baa1e56b3640524e41 Mon Sep 17 00:00:00 2001 From: William Jackson Date: Sun, 8 Nov 2015 09:49:07 +0200 Subject: [PATCH] Update x-listops.js Change default suffix for append[], prepend[] and remove[] operators from 1 to All --- core/modules/filters/x-listops.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/core/modules/filters/x-listops.js b/core/modules/filters/x-listops.js index 8b66a24c6..63edcd142 100644 --- a/core/modules/filters/x-listops.js +++ b/core/modules/filters/x-listops.js @@ -122,10 +122,10 @@ Extended filter operators to manipulate the current list. Appends the items listed in the operand array to the tail of the current list */ exports.append = function (source, operator, options) { - var results = prepare_results(source), - count = parseInt(operator.suffix) || 1, - append = $tw.utils.parseStringArray(operator.operand); - if (append === "") { + var append = $tw.utils.parseStringArray(operator.operand), + results = prepare_results(source), + count = parseInt(operator.suffix) || append.length; + if (append.length === 0) { return results; } if (operator.prefix) { @@ -139,10 +139,10 @@ Extended filter operators to manipulate the current list. Prepends the items listed in the operand array to the head of the current list */ exports.prepend = function (source, operator, options) { - var results = prepare_results(source), - count = parseInt(operator.suffix) || 1, - prepend = $tw.utils.parseStringArray(operator.operand); - if (prepend === "") { + var prepend = $tw.utils.parseStringArray(operator.operand), + results = prepare_results(source), + count = parseInt(operator.suffix) || prepend.length; + if (prepend.length === 0) { return results; } if (operator.prefix) { @@ -156,9 +156,10 @@ Extended filter operators to manipulate the current list. Returns all items from the current list except the items listed in the operand array */ exports.remove = function (source, operator, options) { - var results = prepare_results(source), - count = parseInt(operator.suffix) || 1, - p, len, index, array = $tw.utils.parseStringArray(operator.operand); + var array = $tw.utils.parseStringArray(operator.operand), + results = prepare_results(source), + count = parseInt(operator.suffix) || array.length, + p, len, index; len = array.length - 1; for (p = 0; p < count; ++p) { if (operator.prefix) {