0

If we have two nodes outer and inner, each one of them has shadowRoot

      const inner = document.createElement("span");
      inner.attachShadow({ mode: "open" }).innerHTML = "inner";

      const outer = document.createElement("span");
      outer.attachShadow({ mode: "open" }).append("outer ", inner);

      document.body.append(outer);

enter image description here

Then we select a text exists in both

enter image description here

If we try to get selected text

window.getSelection().toString()

We get 'er ' which is incorrect! Even if try to get selection on the shadowRoot of inner span it not correct.

  • How to get selection is this case?
Zuhair Taha
  • 2,808
  • 2
  • 35
  • 33
  • I'm surprised you can even make that selection as a user. Last time I tried that wasn't even possible to achieve for a user... – connexo Sep 14 '22 at 09:01
  • As per this discussion this is repeat question - you can read about it here https://stackoverflow.com/a/70523247/7255780 – prograk Sep 14 '22 at 09:25

0 Answers0