From 951db23ffde550f442ea2031a36fd0191e0c35bf Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Tue, 23 Jun 2015 11:12:37 +0930 Subject: [PATCH] Revert from a while ago: always append if reference item not found API still needs some work though --- framework/core/js/lib/utils/item-list.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/framework/core/js/lib/utils/item-list.js b/framework/core/js/lib/utils/item-list.js index 0b5bfb9fb..238aa857f 100644 --- a/framework/core/js/lib/utils/item-list.js +++ b/framework/core/js/lib/utils/item-list.js @@ -44,12 +44,18 @@ export default class ItemList { items.forEach(item => { var key = item.position.before || item.position.after; var type = item.position.before ? 'before' : 'after'; + // TODO: Allow both before and after to be specified, and multiple keys to + // be specified for each. + // e.g. {before: ['foo', 'bar'], after: ['qux', 'qaz']} + // This way extensions can make sure they are positioned where + // they want to be relative to other extensions. if (key) { var index = array.indexOf(this[key]); if (index === -1) { - index = type === 'before' ? 0 : array.length; + array.push(item); + } else { + array.splice(index + (type === 'after' ? 1 : 0), 0, item); } - array.splice(index + (type === 'after' ? 1 : 0), 0, item); } });