Browse Source

fix: a.textContent is not a function

Tienson Qin 6 months ago
parent
commit
04edc97e1a
1 changed files with 4 additions and 2 deletions
  1. 4 2
      src/main/frontend/util.cljc

+ 4 - 2
src/main/frontend/util.cljc

@@ -1248,7 +1248,9 @@
 #?(:cljs
    (defn scroll-editor-cursor
      [^js/HTMLElement el & {:keys [to-vw-one-quarter?]}]
-     (when (and el (or (mobile-util/native-platform?) (mobile?)))
+     (when (and el (or web-platform?
+                       (mobile-util/native-platform?)
+                       (mobile?)))
        (let [box-rect    (.getBoundingClientRect el)
              box-top     (.-top box-rect)
              box-bottom  (.-bottom box-rect)
@@ -1260,7 +1262,7 @@
              scroll-top'  (.-scrollTop main-node)
 
              current-pos (get-selection-start el)
-             grapheme-pos (get-graphemes-pos (.-value (.textContent el)) current-pos)
+             grapheme-pos (get-graphemes-pos (.-value el) current-pos)
              mock-text   (some-> (gdom/getElement "mock-text")
                                  gdom/getChildren
                                  array-seq