guardian/scribe — pull request #259 by kekeblom (2014-10-04 01:06:36+00:00)
Title: Get selection from element context instead of using the global context

I was trying to use scribe to edit the contents of an element inside an iframe and ran into an issue. Due to the fact that scribe uses `window.getSelection()` to grab the selection, the selection comes up as empty, since, in my case, the focus is inside the iframe which has its own document context.

This fix grabs the selection using `scribe.el.ownerDocument.getSelection()` always giving you the selection from the element context.

To illustrate the problem I created this jsbin: http://jsbin.com/gafezowidice/4/edit?html,js,console,output

Can anyone think of a case where this approach does not work?