Skip to content

Commit

Permalink
Extend Selector remove item API
Browse files Browse the repository at this point in the history
[Issue] Samsung/TAU-Design-Editor#279
[Problem] Selector item removal API that allows for removing
          items by HTMLElements would be helpful.
[Solution] Extend API to accept both index and HTMLElement

Signed-off-by: Pawel Kaczmarczyk <p.kaczmarczy@samsung.com>
  • Loading branch information
pkaczmarczy committed Aug 26, 2019
1 parent 7549e1c commit df280f8
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/js/profile/wearable/widget/wearable/Selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -1809,18 +1809,26 @@
/**
* Remove item on specific layer
* @method removeItem
* @param {number} index
* @param {number | HTMLElement} arg1 index of element to remove or HTML element to remove
* @public
* @member ns.widget.wearable.Selector
*/
prototype.removeItem = function (index) {
prototype.removeItem = function (arg1) {
var self = this,
ui = self._ui,
element = self.element,
length,
itemsOnLayer = self.options.maxItemNumber;
itemsOnLayer = self.options.maxItemNumber,
index;

removeLayers(self.element, self.options);

if (arg1 instanceof HTMLElement) {
index = ui.items.indexOf(arg1);
} else {
index = arg1;
}

element.removeChild(ui.items[index]);
ui.items = element.querySelectorAll(self.options.itemSelector);
length = ui.items.length;
Expand Down

0 comments on commit df280f8

Please sign in to comment.