From f2e9fab2645e4783e68eae9db92c9270510183ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Fri, 10 Mar 2017 11:43:55 +0100 Subject: [PATCH] Split Item#copyTo() into #addTo() and #copyTo() --- src/item/Item.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/item/Item.js b/src/item/Item.js index 9e1d3417..6334a6eb 100644 --- a/src/item/Item.js +++ b/src/item/Item.js @@ -2522,17 +2522,27 @@ new function() { // Injection scope for hit-test functions shared with project moveBelow: '#insertBelow', /** - * When passed a project, copies the item to the project, - * or duplicates it within the same project. When passed an item, - * copies the item into the specified item. + * Adds it to the specified owner, which can be either a {@link Item} or a + * {@link Project}. + * + * @param {Project|Layer|Group|CompoundPath} owner the item or project to + * add the item to + * @return {Item} the item itself, if it was successfully added + */ + addTo: function(owner) { + return owner._insertItem(undefined, this); + }, + + /** + * Clones the item and adds it to the specified owner, which can be either + * a {@link Item} or a {@link Project}. * * @param {Project|Layer|Group|CompoundPath} owner the item or project to * copy the item to - * @return {Item} the new copy of the item + * @return {Item} the new copy of the item, if it was successfully added */ copyTo: function(owner) { - // Pass false for insert, since we're inserting at a specific location. - return owner._insertItem(undefined, this.clone(false)); + return this.clone(false).addTo(owner); }, /**