@@ -140,6 +140,14 @@ Elm.Native.Graphics.Input = function(elm) {
140 return { _:{}, box:F2(box), events:events };
140 return { _:{}, box:F2(box), events:events };
143+ function setRange(node, start, end, dir) {
144+ if (node.parentNode) {
145+ node.setSelectionRange(start, end, dir);
147+ setTimeout(function(){node.setSelectionRange(start, end, dir);}, 0);
143 function mkTextPool(type) { return function fields(defaultValue) {
151 function mkTextPool(type) { return function fields(defaultValue) {
144 var events = Signal.constant(defaultValue);
152 var events = Signal.constant(defaultValue);
@@ -153,7 +161,7 @@ Elm.Native.Graphics.Input = function(elm) {
153 field.type = type;
161 field.type = type;
154 field.placeholder = fromString(model.placeHolder);
162 field.placeholder = fromString(model.placeHolder);
155 field.value = fromString(model.state.string);
163 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');
157 field.style.border = 'none';
165 field.style.border = 'none';
158 state = model.state;
166 state = model.state;
@@ -202,7 +210,7 @@ Elm.Native.Graphics.Input = function(elm) {
202 if (node.selectionStart !== start
210 if (node.selectionStart !== start
203 || node.selectionEnd !== end
211 || node.selectionEnd !== end
204 || node.selectionDirection !== direction) {
212 || node.selectionDirection !== direction) {
205− node.setSelectionRange(start, end, direction);
213+ setRange(node, start, end, direction);