Selection scope: using context of **last** element used for selection initialization [Bugfix]

Using `window` and `document` globals, from context of last element. Workaround for problems with iframe.