question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Consider removing innerHTML usage

See original GitHub issue

Expected 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:

https://github.com/chartjs/Chart.js/blob/75aa44eef677b790768262638df0de223fd01a56/src/platforms/platform.dom.js#L187-L205

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)

  1. Follow the Firefox addon submission wizard for an addon that includes Chart.min.js as a content_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:closed
  • Created 5 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
benmccanncommented, Dec 12, 2018

You could use document.createElement, appendChild, etc. to create the dom structure without using innerHTML. Feel free to send a PR

1reaction
jeroenheijmanscommented, Dec 13, 2018

Built that branch and verified my app keeps working as expected, and that the Mozilla add on store doesn’t give any warnings anymore.

Thanks!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found