When a Saved Note Becomes HTML
Follow a colleague’s saved note into a dashboard, compare HTML interpretation with literal text, and fix the rendering operation.
You’re reading a preview. Premium includes the full lesson and specialist practice. View the full curriculum.
A note your colleague will read
Imagine you leave a note in a team activity feed. Later, a colleague opens the dashboard. The app should display your words. What happens if your note contains HTML?
The note is saved in a database and returned by an API as JSON. Both steps preserve the string. The decision that matters happens when the dashboard displays it.
Start with ordinary text
A note such as Thanks, team! should appear as a line of text. The original dashboard builds each list item by joining strings:
const row = '<li>' + note.text + '</li>';
list.innerHTML = row;
innerHTML asks the browser to read an HTML string. A normal note looks fine, which can hide the mistake.
Now try <b>Fixture</b>. For this plain-text feature, the angle brackets should remain visible. If the page instead creates a bold element, the note's author has gained control over the page's markup.