Created
June 3, 2016 00:40
-
-
Save jonathansampson/6d09bd6d2e8c22c53868aec42e66b0f9 to your computer and use it in GitHub Desktop.
A polyfill for Range.prototype.intersectsNode
This file contains 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
if ( !Range.prototype.intersectsNode ) { | |
Range.prototype.intersectsNode = function ( node ) { | |
let range = document.createRange(); | |
range.selectNode( node ); | |
return 0 > this.compareBoundaryPoints( Range.END_TO_START, range ) | |
&& 0 < this.compareBoundaryPoints( Range.START_TO_END, range ); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment