Using prototype's methods name as data name causes crash
- Dominant language
- JavaScript
- Stars
- 9.3k
- Forks
- 1.4k
- Avg merge
- 6d 16h
- Merged PRs (30d)
- 1
Description
The following code for donut won't render in firefox
``` javascript
var data = [
[ "watch", 5 ],
[ "def", 4 ],
[ "ghi", 4 ],
[ "jkl", 3 ],
[ "mno", 3 ]
];
var chart = c3.generate({
bindto: '#chart',
data: {
columns: data,
type: 'donut'
},
color: {
pattern: ["#a2d47f", "#ffb377", "#ff7676", "#99e0fc", "#e7acdc"]
},
transition: {
duration: 500
},
legend: {
show: true
}
});
```
I investigated and found out its because the name of 1 element in 'data' array is watch, and for firefox 'watch' is a function for object data type.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/watch
Problem is being caused at the code at line number 1848:
``` javascript
$$.setTargetType($$.mapToIds(targets).filter(function (id) { return ! (id in config.data_types); }), config.data_type);
```
This is causing the 0th element in data[] to get filtered out, since for 'watch' the expression `! (id in config.data_types)` returns false since watch is already present as a function.
The name related problem is also coming at line number 4896 inside the method `generateColor()`, and might come at other places also.
Contributor guide
Assessment
This issue has not been assessed yet.