on master help sign in
Fix Float32Array bug in IE. Fix input selection bug in IE.
commit582a4c5ee2fc6869934d9c6040fe5c7302461a9d authorevancz <info@elm-lang.org> dateWed 22 May 2013, 14:05 (13 years ago) parentd9d6ce5
3 files changed+30−5
libraries/Native/Graphics/Input.js+10−2 libraries/Native/Matrix2D.js+14−2 runtime/Render/Collage.js+6−1
libraries/Native/Graphics/Input.js+10−2
@@ -140,6 +140,14 @@ Elm.Native.Graphics.Input = function(elm) {
140140 return { _:{}, box:F2(box), events:events };
141141 }
142142
143+ function setRange(node, start, end, dir) {
144+ if (node.parentNode) {
145+ node.setSelectionRange(start, end, dir);
146+ } else {
147+ setTimeout(function(){node.setSelectionRange(start, end, dir);}, 0);
148+ }
149+ }
150+
143151 function mkTextPool(type) { return function fields(defaultValue) {
144152 var events = Signal.constant(defaultValue);
145153
@@ -153,7 +161,7 @@ Elm.Native.Graphics.Input = function(elm) {
153161 field.type = type;
154162 field.placeholder = fromString(model.placeHolder);
155163 field.value = fromString(model.state.string);
156− field.setSelectionRange(model.state.selectionStart, model.state.selectionEnd);
164+ setRange(field, model.state.selectionStart, model.state.selectionEnd, 'forward');
157165 field.style.border = 'none';
158166 state = model.state;
159167
@@ -202,7 +210,7 @@ Elm.Native.Graphics.Input = function(elm) {
202210 if (node.selectionStart !== start
203211 || node.selectionEnd !== end
204212 || node.selectionDirection !== direction) {
205− node.setSelectionRange(start, end, direction);
213+ setRange(node, start, end, direction);
206214 }
207215 }
208216
libraries/Native/Matrix2D.js+14−2
@@ -5,8 +5,20 @@ Elm.Native.Matrix2D = function(elm) {
55 elm.Native = elm.Native || {};
66 if (elm.Native.Matrix2D) return elm.Native.Matrix2D;
77
8− if (typeof Float32Array === 'undefined'){ Float32Array = Array; }
9− var A = Float32Array;
8+ var A;
9+ if (typeof Float32Array === 'undefined') {
10+ A = function(arr) {
11+ this.length = arr.length;
12+ this[0] = arr[0];
13+ this[1] = arr[1];
14+ this[2] = arr[2];
15+ this[3] = arr[3];
16+ this[4] = arr[4];
17+ this[5] = arr[5];
18+ };
19+ } else {
20+ A = Float32Array;
21+ }
1022
1123 // layout of matrix in an array is
1224 //
runtime/Render/Collage.js+6−1
@@ -279,7 +279,12 @@ function updateTracker(w,h,div) {
279279 if (!container) {
280280 div.appendChild(container);
281281 } else {
282− div.insertBefore(container, kids[i]);
282+ var kid = kids[i];
283+ if (kid) {
284+ div.insertBefore(container, kid);
285+ } else {
286+ div.appendChild(container);
287+ }
283288 }
284289 }
285290 // we have added a new node, so we must step our position