I am trying to store the value of window.getSelection(), but this value seems to change if the user selects another selection.
In my code below, I have stored the initial user's selection. I then create my form (which takes a bit of time), and when the form is finished being created I fill in the form with the user's selection. Now during the time when the form is being created, the user may select some other text, and now the object stored in my selection variable has changed. How would I prevent the value of selection from being changed?
var selection = window.getSelection();
createForm(function() {
fillInForm(selection);
});
EDIT - I need to keep the DOM structure of the selection as the form references the position of the selected text.