chart.js (2,3,4,master) do not work on evironments loading also prototype.js
- Dominant language
- JavaScript
- Stars
- 67.7k
- Forks
- 11.9k
- Avg merge
- 7h 39m
- Merged PRs (30d)
- 5
Description
### Expected behavior
The **chart.js** library will render the chart even if **prototype.js** is loaded.
### Current behavior
Reproducer page: https://jvanek.fedorapeople.org/charts/ ; namely: https://jvanek.fedorapeople.org/charts/impl/index4-umd-deprototyped.html
I maintain set of jenkins plugins, built around chartjs1. Finally (!) I kicked myself lot enough to port them to chart.js 4, thus I set [this](https://github.com/judovana/ChartJsMigration/) page to track the migration 1->2->3-4. At the end, I finished only 4, as it was very smooth.
Unluckily, when I finished the migration, I found the chart is not showing properly in jenkins, although identical page shows properly outside jenkins. I found, that loading of **prototype.js** http://prototypejs.org/ (in any version) is killing prototpye search in chart.js.
I debugged it to call of
```
getPrototypeOf() {
return Reflect.getPrototypeOf(scopes[0]);
},
```
However, it seesm it is broken elsewhere, as without prototype.js scopes is array of length 2, but with prototype.js it is empty array. To found it reach over my JS skill.
```
Uncaught TypeError: `target` argument of Reflect.getPrototypeOf must be an object, got undefined
getPrototypeOf helpers.config.js:57
Ue helpers.config.js:181
get helpers.config.js:205
get helpers.config.js:120
Xe helpers.config.js:188
get helpers.config.js:119
update core.controller.js:493
wn core.controller.js:206
index4-umd-deprototyped.html:89
```
Note, if you remove prototype.js from jenkins, the charts appear.But everything else case to work :)
Additional resources:
[ 2017 mentions conflict with wordpress, solved by removal of prototype.js from project](https://github.com/chartjs/Chart.js/issues/5059) . Useless note, it is same trace I hit on chartj2 even with prototype.js 1.7
[ 2018 mentions it on jenkinsci-dev group](https://groups.google.com/g/jenkinsci-dev/c/egxqt4cAwF8) This mentions, update to 1.7.3 is fixing the issue. It did not worked for me
[relevant to above. PR to bump jenkins protype.js from 1.7 to 1.7.3. Caused issues, was reverted, afaik jenkins is still on 1.7](https://github.com/jenkinsci/jenkins/pull/3277)
[ 2019 stackoweeflow exact issue (with possible solution)](https://stackoverflow.com/questions/49773719/why-chart-js-library-stops-working-if-i-modify-object-prototype)
[ 2020, github issue for chartjs. ](https://github.com/chartjs/Chart.js/issues/7935)Not 100% related, by mention security issues and is about same function
[One of the few CVEs related to chart.js prototyep polution](https://vulners.com/osv/OSV:GHSA-H68Q-55JF-X68W)
### Reproducible sample
https://jvanek.fedorapeople.org/charts/impl/index4-umd-deprototyped.html
### Optional extra steps/info to reproduce
_No response_
### Possible solution
_No response_
### Context
_No response_
### chart.js version
4.2.1
### Browser name and version
latest firefox and chromium
### Link to your project
https://github.com/judovana/jenkins-chartjs-plugin
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.