Skip to content

Commit

Permalink
Fix error with null rules list
Browse files Browse the repository at this point in the history
  • Loading branch information
clehner committed Aug 7, 2015
1 parent 74781e4 commit 6c6ab5e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/sheet.js
Expand Up @@ -412,7 +412,8 @@ RulesList.prototype.toJSON = function() {
RulesList.prototype.diff = Array.pool(function(rulesDiff, other) {
if (!other) return;
var skip = 0,
minLength = Math.min(this.rules.length, other.rules.length);
otherLength = other.rules ? other.rules.length : 0;
minLength = Math.min(this.rules.length, otherLength);

// handle changed and added rules
for (var i = 0; i < minLength; i++) {
Expand Down Expand Up @@ -440,14 +441,14 @@ RulesList.prototype.diff = Array.pool(function(rulesDiff, other) {
}
}

if (i < other.rules.length) {
if (i < otherLength) {
//console.log('push more', skip, theirRules.slice(i));
if (skip) {
rulesDiff.push({
skip: skip
});
}
for (; i < other.rules.length; i++) {
for (; i < otherLength; i++) {
rulesDiff.push(other.rules[i].toJSON());
}
} else if (i < this.rules.length) {
Expand Down

0 comments on commit 6c6ab5e

Please sign in to comment.