Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/browser/ui/dom/setInnerHTML.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,13 @@ if (ExecutionEnvironment.canUseDOM) {
if (WHITESPACE_TEST.test(html) ||
html[0] === '<' && NONVISIBLE_TEST.test(html)) {
// Recover leading whitespace by temporarily prepending any character.
// \uFEFF has the potential advantage of being zero-width/invisible.
node.innerHTML = '\uFEFF' + html;
// \uFEFF (zero width no-break space) is deprecated by Unicode in favor
// of \u2060 (word joiner) which are theoretically favorable for being
// zero width/invisible. However, '\uFEFF' when double-uglified is
// stripped entirely and '\u2060' when uglified is decoded. Any imagined
// advantage of using a zero width/invisible char is not proven and not
// worth the apparent dangers associated with it. Use a safe ASCII char.
node.innerHTML = '!' + html;

// deleteData leaves an empty `TextNode` which offsets the index of all
// children. Definitely want to avoid this.
Expand Down