heatmap.js: Cannot assign to read only property 'data' of object

When using heatmap.js on certain browsers, this error Cannot assign to read only property 'data' of object shows up. screen shot 2016-09-01 at 11 18 47 am

I’m able to reproduce on chromium that is packaged with electron version 1.3.3.

This seems to happen because the data property of ImageData object is being replaced directly in this part of the code. https://github.com/pa7/heatmap.js/blob/master/src/renderer/canvas2d.js#L280

data property seems to be read only on certain browser versions. To fix it, we need to delete this line because imgData and img.data points to the same reference. Any modifications you do to imgData is already reflected to img.data. I’ll put up a PR soon.

About this issue

  • Original URL
  • State: open
  • Created 8 years ago
  • Reactions: 9
  • Comments: 15

Commits related to this issue

Most upvoted comments

I’m facing the same issue using heatmapjs in my Angular application.

Any suggestions on how to include this fix from package.json (eg. load the library from that fork) ?

EDIT: This seems to work: "heatmap.js": "https://github.com/ionata/heatmap.js.git" instead of "heatmap.js": "^2.0.5"

so how can this problem be solved in version 2.0.5

The fork shared by jakob-e works for me too. I’m using rollup to bundle everything. This has been open for some time. That fork is not on npm. What should be done next?

Same here. I found that problem occur only on prod env when all my scripts are bundled and “use strict” is on top of bundle.