Skip to content

Commit

Permalink
fix(bower): resolve error _updateTotal
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgecasar committed Apr 26, 2017
1 parent 780b2ce commit 20084ba
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions payment-request.html
Original file line number Diff line number Diff line change
Expand Up @@ -233,15 +233,19 @@
this.splice(property, 0, this[property].length - 1);
}
// Add items from added nodes
observerInfo.addedNodes.forEach(function (node) {
observerInfo.addedNodes.filter(this._isElementNode).forEach(function (node) {
this.splice(property, this[property].length, 0, node.dictionary);
}.bind(this));
// Remove items from removed nodes
observerInfo.removedNodes.forEach(function (node) {
observerInfo.removedNodes.filter(this._isElementNode).forEach(function (node) {
this.splice(property, this[property].indexOf(node.dictionary), 1);
}.bind(this));
},

_isElementNode: function(node) {
return (node.nodeType === Node.ELEMENT_NODE);
},

__observerNode: function (node) {
return '_' + node + 'Observer';
},
Expand All @@ -265,6 +269,8 @@
if (!total) {
total = this.create('payment-item');
totalDom.appendChild(total);
this.importHref('../payment-item.html', this._updateTotal.bind(this), console.error.bind(console), true);
return;
}
var currency = this.items.length ?
this.items[0].amount.currency :
Expand All @@ -273,14 +279,11 @@
for (var i = 0; i < this.items.length; i++) {
value += this.items[i].amount.value;
}
total.set('label', this.label || 'Total');
total.set('value', value);
total.set('currency', currency);
total.label = this.label || 'Total';
total.value = value;
total.currency = currency;

this._setTotal({
label: total.label,
amount: total.amount
});
this._setTotal(total.dictionary);
},

_computeDetails: function (total, items) {
Expand Down

0 comments on commit 20084ba

Please sign in to comment.