Replies: 1 comment 2 replies
-
I believe the right tool for the job here is element.insertAdjacentHTML so that text/HTML can be appended after without trashing previous nodes. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
If you do this, any elements that are already there will be completely replaced with fresh ones. This means that properties that are local to those elements, such as event listeners, are lost. Currently the only way I can think of to add plain text through the constructor or append() without replacing elements is to wrap it in a span tag.
I suggest document.createTextNode. In fact, having a python class to wrap TextNodes would be cool.
Beta Was this translation helpful? Give feedback.
All reactions