Skip to content

Commit

Permalink
Log deprecation message in console when not using "chart-" prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
jtblin committed Aug 30, 2015
1 parent 6eab366 commit 31be999
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
11 changes: 11 additions & 0 deletions angular-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@

if (usingExcanvas) window.G_vmlCanvasManager.initElement(elem[0]);

['data', 'labels', 'options', 'series', 'colours', 'legend', 'click', 'hover'].forEach(deprecated);
function aliasVar (fromName, toName) {
scope.$watch(fromName, function (newVal) {
if (typeof newVal === 'undefined') return;
Expand Down Expand Up @@ -198,6 +199,16 @@
});
if (scope.legend && scope.legend !== 'false') setLegend(elem, chart);
}

function deprecated (attr) {
if (typeof console !== 'undefined' && ChartJs.getOptions().env !== 'test') {
var warn = typeof console.warn === 'function' ? console.warn : console.log;
if (!! scope[attr]) {
warn.call(console, '"%s" is deprecated and will be removed in a future version. ' +
'Please use "chart-%s" instead.', attr, attr);
}
}
}
}
};
};
Expand Down
Loading

0 comments on commit 31be999

Please sign in to comment.