on master help sign in
Fix sliceRight: prevent appending empty nodes
9b2db8eChristian Widera
libraries/Native/Array.js+6−4
@@ -309,10 +309,12 @@ Elm.Native.Array.make = function(elm) {
309
309
310 // Create new node.
310 // Create new node.
311 var newA = { ctor:"_Array", height:a.height
311 var newA = { ctor:"_Array", height:a.height
312− , table:a.table.slice(0, right + 1)
312+ , table:a.table.slice(0, right)
313− , lengths:a.lengths.slice(0, right + 1) };
313+ , lengths:a.lengths.slice(0, right) };
314+ if (sliced.table.length > 0) {
314− newA.table[right] = sliced;
315+ newA.table[right] = sliced;
315− newA.lengths[right] = length(sliced) + (right > 0 ? newA.lengths[right - 1] : 0);
316+ newA.lengths[right] = length(sliced) + (right > 0 ? newA.lengths[right - 1] : 0);
317+ }
316 return newA;
318 return newA;
317 }
319 }
318
320