]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Better error message when importing charts incorrectly. (#7790)
authorLAU <34402401+Lautarourtiaga@users.noreply.github.com>
Mon, 14 Sep 2020 13:57:50 +0000 (10:57 -0300)
committerGitHub <noreply@github.com>
Mon, 14 Sep 2020 13:57:50 +0000 (09:57 -0400)
* Created a better error message when chartjs can't find an element in the DOM.
Also, prevented an exception when trying to find the canvas assuming is an array. When it could also be null.

* Exception is not thrown anymore in getCanvas. Now this pr only prevents the
item.lenght exception and logs a better error when a chart cant be created.

* Deleted error description because i forgot chartjs is used in varois other ways than importing, also used isArray from helpers.core

* isArray check deleted because the type of the dom element received in getCanvas could be not only an array.

Co-authored-by: Lautaro Alonso Urtiaga <lautaro.urtiaga@10pines.com>
src/core/core.controller.js

index 2a932062c4fa11b782909285d40c0e6cdbd57a89..9ea1dce06b3c9f400bf1f66c207d6fc5dc444767 100644 (file)
@@ -202,7 +202,7 @@ function isDomSupported() {
 function getCanvas(item) {
        if (isDomSupported() && typeof item === 'string') {
                item = document.getElementById(item);
-       } else if (item.length) {
+       } else if (item && item.length) {
                // Support for array based queries (such as jQuery)
                item = item[0];
        }