Skip to content

Commit

Permalink
Refactor unshift method.
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinRixham committed Nov 19, 2016
1 parent f7224ef commit da5eb29
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/array/ArrayElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ define(["array/ArrayItemElement"], function(ArrayItemElement) {
element.appendChild(child.clone());
};

this.prepend = function() {

element.insertBefore(child.clone(), element.firstChild);
};

this.removeFirst = function() {

if (element.firstElementChild) {
Expand Down
7 changes: 3 additions & 4 deletions src/array/method/Unshift.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ define([

for (var j = 0; j < elements.length; j++) {

var element = elements[j].get();
var child = elements[j].getChild();
var element = elements[j];

element.insertBefore(child.clone(), element.firstChild);
property.applyBinding(new DOMElement(element), 0, model);
element.prepend();
property.applyBinding(new DOMElement(element.get()), 0, model);
}
}

Expand Down

0 comments on commit da5eb29

Please sign in to comment.