[BUG] Consider removing innerHTML usage
See original GitHub issueExpected Behavior
Firefox addons being accepted without warnings around Chart.js.
Current Behavior
Submitting an addon to the Firefox store gives:
⚠ Unsafe assignment to innerHTML
Warning: Due to both security…
When searching through master
, I get one offending line:
At first glance this seems to be the same usage in the minified build.
Possible Solution
Unsure, but perhaps there’s another way to do the same thing in that line?
Steps to Reproduce (for bugs)
- Follow the Firefox addon submission wizard for an addon that includes
Chart.min.js
as acontent_script
Context
Reviews of such addons tend to take longer, or the addon might even be rejected based on this.
Environment
- Chart.js version: 2.7.3
- Browser name and version: n/a
- Link to your project: n/a
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Manipulating innerHTML removes the event handler of a child ...
Modifying innerHTML causes the content to be re-parsed and DOM nodes to be recreated, losing the handlers you have attached. Appending elements as...
Read more >DOM Manipulation and the Dangers of 'innerHTML'
The most obvious conclusion from our brief experiment is innerHTML removes event listeners that have previously been added to the DOM. Since the...
Read more >Element.innerHTML - Web APIs | MDN
Setting the value of innerHTML removes all of the element's descendants and replaces them with nodes constructed by parsing the HTML given in ......
Read more >DO NOT use innerHTML - 2 BIG Reasons Why - YouTube
Do not use innerHTML. This video shows 2 HUGE reasons why you should avoid innerHTML and use alternatives instead.
Read more >Is it safe to use innerHTML in JavaScript? - YouTube
In today's JavaScript tutorial we're going to look at the innerHTML property that's available in JavaScript to dynamically update elements ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You could use
document.createElement
,appendChild
, etc. to create the dom structure without usinginnerHTML
. Feel free to send a PRBuilt that branch and verified my app keeps working as expected, and that the Mozilla add on store doesn’t give any warnings anymore.
Thanks!