Skip to content

Commit

Permalink
handle bad safari behavior w/ respect to text selection API
Browse files Browse the repository at this point in the history
fixes bigskysoftware/htmx#438

thank you @pavelfeldman for finding the root cause!
  • Loading branch information
strangeRabbit777 authored and carson committed Apr 13, 2021
1 parent 9ee0a9f commit dc5fc84
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/htmx.js
Original file line number Diff line number Diff line change
Expand Up @@ -2274,11 +2274,15 @@ return (function () {
try {

var activeElt = document.activeElement;
var selectionInfo = {
elt: activeElt,
start: activeElt ? activeElt.selectionStart : null,
end: activeElt ? activeElt.selectionEnd : null
};
try {
var selectionInfo = {
elt: activeElt,
start: activeElt ? activeElt.selectionStart : null,
end: activeElt ? activeElt.selectionEnd : null
};
} catch (e) {
var selectionInfo = {}; // safari issue - see https://github.com/microsoft/playwright/issues/5894
}

var settleInfo = makeSettleInfo(target);
selectAndSwap(swapSpec.swapStyle, target, elt, serverResponse, settleInfo);
Expand Down

0 comments on commit dc5fc84

Please sign in to comment.