Created
January 16, 2017 15:10
-
-
Save juliandescottes/59ed37156b8087e1c0599904ceadc664 to your computer and use it in GitHub Desktop.
Some random code to inspect the selection in the computed view
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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