From 665fc4bda76f97c0a023f96e65fba3527fec6a3b Mon Sep 17 00:00:00 2001 From: carson Date: Tue, 13 Apr 2021 15:36:37 -0600 Subject: [PATCH] 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! --- src/htmx.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/htmx.js b/src/htmx.js index afa5f50b..8e4adddc 100644 --- a/src/htmx.js +++ b/src/htmx.js @@ -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);