Skip to content

Instantly share code, notes, and snippets.

@juliandescottes
Created January 16, 2017 15:10
Show Gist options
  • Save juliandescottes/59ed37156b8087e1c0599904ceadc664 to your computer and use it in GitHub Desktop.
Save juliandescottes/59ed37156b8087e1c0599904ceadc664 to your computer and use it in GitHub Desktop.
Some random code to inspect the selection in the computed view
let win = this.styleWindow;
let selection = win.getSelection();
let computedViewRanges = [];
for (let i = 0; i < selection.rangeCount; i++) {
let range = selection.getRangeAt(i);
if (!range.collapsed) {
let ancestor = range.commonAncestorContainer;
if (this.element == ancestor || this.element.contains(ancestor)) {
console.log("valid range", range);
computedViewRanges.push(range);
}
}
}
computedViewRanges.forEach(r => {
console.log(r.toString());
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment