Empty text node at the start and the end of the element #12538
Unanswered
anatoliilitvinovr
asked this question in
Help/Questions
Replies: 1 comment 3 replies
-
Those empty text nodes are fragment anchors used by Vue to manage fragments. In your case, the |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Intro
Hey!
In Vue, every array of nodes (elements) is wrapped by an empty text node at the start and the end so that Vue can place these elements in it.
Here is a short code snippet to reproduce this:
In the console, you will see something like this:
The problem
I need to get the current document selection via the "selection change" DOM Event after the "cmd+left"/"cmd+right" hotkey combo is fired. The "cmd+left"/"cmd+right" hotkey makes the cursor move to the start/end of the line where the cursor is.
Here is a catch: when you do "cmd+left"/"cmd+right" the cursor will move to the first/last "#text" node, which is added by Vue but is not expected for me. (I expect that selection will move to the first/last "#text" node, which is in one of the "div" nodes)
As I tested, no other Web Framework (React, Angular, Solid) does the same.
Do you know how to manage this? Maybe there is a way available to prevent the creation of these "#text" nodes? Any ideas?
Beta Was this translation helpful? Give feedback.
All reactions