on master help sign in
Fix Array.append with an empty array
97743d8Christian Widera
libraries/Native/Array.js+5−3
@@ -345,9 +345,11 @@ Elm.Native.Array.make = function(elm) {
345 // TODO: Add support for appending trees of different sizes. Current
345 // TODO: Add support for appending trees of different sizes. Current
346 // behavior will just rise the lower tree and then append them.
346 // behavior will just rise the lower tree and then append them.
347 function append(a,b) {
347 function append(a,b) {
348+ if (a.table.length == 0) return b;
349+ if (b.table.length == 0) return a;
348− if (b.height > a.height) { return append(parentise(a, b.height), b); }
350+ if (b.height > a.height) return append(parentise(a, b.height), b);
349− if (a.height > b.height) { return append(a, parentise(b, a.height)); }
351+ if (a.height > b.height) return append(a, parentise(b, a.height));
350− if (a.height == 0) { return append(parentise(a, 1), parentise(b, 1)); }
352+ if (a.height == 0) return append(parentise(a, 1), parentise(b, 1));
351
353
352 var c = append_(a, b);
354 var c = append_(a, b);
353 if (c[1].table.length > 0) {
355 if (c[1].table.length > 0) {