Chart.js icon indicating copy to clipboard operation
Chart.js copied to clipboard

Firefox: document.defaultView.getComputedStyle is null

Open drewjenkins opened this issue 8 years ago • 6 comments

It's difficult to produce a codepen for this one since it involves loading an iFrame with display: none, but the bug is pretty much what the title says. This is a documented issue in Firefox.

See https://bugzilla.mozilla.org/show_bug.cgi?id=548397

To workaround the issue, you need to account for the fact that getComputedStyle can potentially return a null value

The following function is in core.helpers.js

	helpers.getStyle = function(el, property) {
		return el.currentStyle ?
			el.currentStyle[property] :
			document.defaultView.getComputedStyle(el, null).getPropertyValue(property);
	};

This will be fixed if that function is changed to something like the following

	helpers.getStyle = function(el, property) {
                if(el.currentStyle) return el.currentStyle[property];
                var computedStyle = document.defaultView.getComputedStyle(el, null);
                if(computedStyle) return computedStyle.getPropertyValue(property);
                return 0;
	};

I'm not keen on the specifics of what returning 0 would mean, but hopefully you get the gist of the problem

drewjenkins avatar Feb 26 '18 21:02 drewjenkins

since it is unlikely that firefox will fix this in a timely manner, it would be nice if we could find a solution for ChartJS in the meantime.

robske110 avatar May 13 '18 09:05 robske110

Do we have news here? Some prevision?

lacerdev avatar Jun 21 '18 16:06 lacerdev

Hit the same error - would be nice to find a fix for this!

wowcut avatar Jul 18 '18 19:07 wowcut

This bug has been fixed in FireFox -- https://bugzilla.mozilla.org/show_bug.cgi?id=1467722 I tested on 62.0b17 and it finally works like in all the other browsers. This issue should be closed as soon as FireFox 62 is released, which should be on the 05.09.2018.

Firefox-ESR users will have to wait some more, but ESR is not actually very wide-spread, even companies have the "normal" Firefox most of the time. (09.07.2019)

robske110 avatar Aug 16 '18 08:08 robske110

@simonbrunel @kurkle @nagix @benmccann seems like this can be closed as resolved?

etimberg avatar Feb 10 '19 01:02 etimberg

Agreed

benmccann avatar Feb 10 '19 01:02 benmccann