diff --git a/libraries/Native/Graphics/Input.js b/libraries/Native/Graphics/Input.js index a83cff9..3d29db1 100644 --- a/libraries/Native/Graphics/Input.js +++ b/libraries/Native/Graphics/Input.js @@ -140,6 +140,14 @@ Elm.Native.Graphics.Input = function(elm) { return { _:{}, box:F2(box), events:events }; } + function setRange(node, start, end, dir) { + if (node.parentNode) { + node.setSelectionRange(start, end, dir); + } else { + setTimeout(function(){node.setSelectionRange(start, end, dir);}, 0); + } + } + function mkTextPool(type) { return function fields(defaultValue) { var events = Signal.constant(defaultValue); @@ -153,7 +161,7 @@ Elm.Native.Graphics.Input = function(elm) { field.type = type; field.placeholder = fromString(model.placeHolder); field.value = fromString(model.state.string); - field.setSelectionRange(model.state.selectionStart, model.state.selectionEnd); + setRange(field, model.state.selectionStart, model.state.selectionEnd, 'forward'); field.style.border = 'none'; state = model.state; @@ -202,7 +210,7 @@ Elm.Native.Graphics.Input = function(elm) { if (node.selectionStart !== start || node.selectionEnd !== end || node.selectionDirection !== direction) { - node.setSelectionRange(start, end, direction); + setRange(node, start, end, direction); } } diff --git a/libraries/Native/Matrix2D.js b/libraries/Native/Matrix2D.js index b7e8439..cb97b29 100644 --- a/libraries/Native/Matrix2D.js +++ b/libraries/Native/Matrix2D.js @@ -5,8 +5,20 @@ Elm.Native.Matrix2D = function(elm) { elm.Native = elm.Native || {}; if (elm.Native.Matrix2D) return elm.Native.Matrix2D; - if (typeof Float32Array === 'undefined'){ Float32Array = Array; } - var A = Float32Array; + var A; + if (typeof Float32Array === 'undefined') { + A = function(arr) { + this.length = arr.length; + this[0] = arr[0]; + this[1] = arr[1]; + this[2] = arr[2]; + this[3] = arr[3]; + this[4] = arr[4]; + this[5] = arr[5]; + }; + } else { + A = Float32Array; + } // layout of matrix in an array is // diff --git a/runtime/Render/Collage.js b/runtime/Render/Collage.js index fc4b22d..cc5bbcd 100644 --- a/runtime/Render/Collage.js +++ b/runtime/Render/Collage.js @@ -279,7 +279,12 @@ function updateTracker(w,h,div) { if (!container) { div.appendChild(container); } else { - div.insertBefore(container, kids[i]); + var kid = kids[i]; + if (kid) { + div.insertBefore(container, kid); + } else { + div.appendChild(container); + } } } // we have added a new node, so we must step our position