This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
Specification: http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html Section: http://www.whatwg.org/specs/web-apps/current-work/#textFieldSelection Comment: Feature request: element.replaceSelection(str) should change the text field's value by replacing the current selection with the provided string, which should then be the new selection. This is apparently supported well in IE's proprietary equivalent, and a MediaWiki developer pointed it out as one of the significant problems he ran into with the standard approach: https://secure.wikimedia.org/wikipedia/mediawiki/wiki/User:Catrope/W3C_Range_f eature_requests#Changing_the_text_contents_of_a_range I think this is simple enough to spec before implementation, if implementers are interested, to avoid the whole vendor prefix rigamarole. Posted from: 68.175.61.233
Aryeh: Is there an API for this kind of thing already, by any chance?
If there was an API, I wouldn't have filed this bug. :) With DOM Range, you should be able to emulate it pretty easily via deleteContents() and insertNode(), although that's not specced and I haven't tried it. But for textbox/input selections, which are different because their contents aren't in the DOM, there's no standard API to do this. Looking back at this issue, though, I'm not sure this is necessary, and if it is necessary not sure it's the right way to fix it. Browsers could make it more efficient as it stands, namely make input.value = input.value.substr(0, input.selectionStart) + someText + input.value.substr(input.selectionEnd); more efficient somehow for large input values. And if that's not the right approach, I don't think it actually makes sense to tie this to the user's selection -- maybe you want to replace some slice for some other reason. So I'm going to resolve INVALID, on reflection. We probably have better things to do. If there are performance problems with existing browsers, bugs should be filed on them, and we can consider new features if they think that's the best way to solve the problem.
mass-moved component to LC1