Re:A little bit of plain JavaScript can do a lot
by CodesInChaos on Monday June 22, 2020 @04:17AM
(#23598211)
The problem is that the code $element("span", text) looks harmless, appears to work, and yet is dangerously wrong.
Dynamically setting text is very common. While dynamically setting innerHTML is a rare and dangerous operation which should be explicit in the code. The alternative syntax also supported by this function $element("span", { innerHTML: html }) is much better.
Dynamically setting text is very common. While dynamically setting innerHTML is a rare and dangerous operation which should be explicit in the code. The alternative syntax also supported by this function $element("span", { innerHTML: html }) is much better.