Elm 0.8 → 0.8.0.1
raw patch · 2 files changed
+35/−9 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- Elm.cabal +1/−1
- elm-runtime.js +34/−8
Elm.cabal view
@@ -1,5 +1,5 @@ Name: Elm-Version: 0.8+Version: 0.8.0.1 Synopsis: The Elm language module. Description: Elm aims to make client-side web-development more pleasant. It is a statically/strongly typed, functional reactive
elm-runtime.js view
@@ -116,8 +116,9 @@ t.style.cssFloat = "left"; elm.node.appendChild(t); - var w = t.clientWidth; - var h = t.clientHeight; + var style = window.getComputedStyle(t, null); + var w = Math.ceil(style.getPropertyValue("width").slice(0,-2) - 0); + var h = Math.ceil(style.getPropertyValue("height").slice(0,-2) - 0); elm.node.removeChild(t); return Tuple2(w,h); } @@ -521,8 +522,20 @@ 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 // @@ -2232,7 +2245,7 @@ }); } - return { _:{}, button:F4(button), events:events }; + return { _:{}, customButton:F4(button), events:events }; } @@ -2269,6 +2282,14 @@ 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); @@ -2282,7 +2303,7 @@ 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; @@ -2331,7 +2352,7 @@ if (node.selectionStart !== start || node.selectionEnd !== end || node.selectionDirection !== direction) { - node.setSelectionRange(start, end, direction); + setRange(node, start, end, direction); } } @@ -5015,7 +5036,12 @@ 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