Polyfill caretRangeFromPoint()
Gecko did not implment the older caretRangeFromPoint() and instead implemented the newer caretPositionFromPoint()
This commit is contained in:
parent
651231fbc1
commit
099d48ef48
@ -16,6 +16,19 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// Polyfill caretRangeFromPoint() using the newer caretPositionFromPoint()
|
||||
if (!document.caretRangeFromPoint){
|
||||
document.caretRangeFromPoint = function polyfillcaretRangeFromPoint(x,y){
|
||||
let range = document.createRange();
|
||||
let position = document.caretPositionFromPoint(x,y);
|
||||
if (!position) {
|
||||
return null;
|
||||
}
|
||||
range.setStart(position.offsetNode, position.offset);
|
||||
range.setEnd(position.offsetNode, position.offset);
|
||||
return range;
|
||||
};
|
||||
}
|
||||
|
||||
class Range {
|
||||
constructor(range) {
|
||||
|
Loading…
Reference in New Issue
Block a user