handle bad safari behavior w/ respect to text selection API

fixes https://github.com/bigskysoftware/htmx/issues/438

thank you @pavelfeldman for finding the root cause!
This commit is contained in:
carson 2021-04-13 15:36:37 -06:00
parent 6f8899f6fd
commit 665fc4bda7

View File

@ -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);