@@ -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