Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-49319

Old Prototype library causes problems with modern UI frameworks

      Jenkins bundles an ancient release of Prototype.js (1.7 in war from 2010, 1.6.0.2 in Stapler from 2008). These releases are not compatible with all features of modern JS frameworks like jQuery and Chart.js and Bootstrap. In order to use other libraries we should upgrade to the latest release 1.7.3 (still old  - 2015 - but with several fixes). 

      E.g., with the bundles 1.7 version the simple 'Hello World' is not shown due to a JS error. With version 1.7.3 the error disappears.

       

          [JENKINS-49319] Old Prototype library causes problems with modern UI frameworks

          Ulli Hafner added a comment -

          Here is an example of the upcoming release of analysis-core: Priority Doughnut Graph. If I change the graph type to a bar-chart then the error in the stack trace (comment before) appears.

          Ulli Hafner added a comment - Here is an example of the upcoming release of analysis-core: Priority Doughnut Graph . If I change the graph type to a bar-chart then the error in the stack trace (comment before) appears.

          Code changed in jenkins
          User: Ulli Hafner
          Path:
          war/src/main/webapp/scripts/prototype.js
          http://jenkins-ci.org/commit/jenkins/5ed43002d7daca06676c565aab18c1842123281f
          Log:
          [FIXED JENKINS-49319] Upgrade to Prototype 1.7.3.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Ulli Hafner Path: war/src/main/webapp/scripts/prototype.js http://jenkins-ci.org/commit/jenkins/5ed43002d7daca06676c565aab18c1842123281f Log: [FIXED JENKINS-49319] Upgrade to Prototype 1.7.3.

          Oleg Nenashev added a comment -

          The fix has been integrated towards 2.110. I am not marking it as LTS candidate, because it seems to be a bit risky to backport it. drulli please mark it as LTS candidate if you need it in the release

          Oleg Nenashev added a comment - The fix has been integrated towards 2.110. I am not marking it as LTS candidate, because it seems to be a bit risky to backport it. drulli please mark it as LTS candidate if you need it in the release

          Ulli Hafner added a comment -

          Hmm, seems to be easier to switch a UI library in my plugins rather then replace this library in core Jenkins.

          Ulli Hafner added a comment - Hmm, seems to be easier to switch a UI library in my plugins rather then replace this library in core Jenkins.

          Sverre Moe added a comment -

          This issue caught my eye, when I was trying to solve the Jenkins slow loading problem reported in JENKINS-56243. After upgrading to Jenkins 2.181 loading was fast again, but for some multibranch projects loading a branch seemd to load completely, but hang in there for 30+ seconds and it seems prototype.js was the culprit that did not quite finish.

          Sverre Moe added a comment - This issue caught my eye, when I was trying to solve the Jenkins slow loading problem reported in JENKINS-56243 . After upgrading to Jenkins 2.181 loading was fast again, but for some multibranch projects loading a branch seemd to load completely, but hang in there for 30+ seconds and it seems prototype.js was the culprit that did not quite finish.

          Hello,
          we need this fix also in the LTS version of Jenkins. What do I have to do, to get this fix?

          Is it possible to use other plugins to workaround this problem?

          Christian Kipping added a comment - Hello, we need this fix also in the LTS version of Jenkins. What do I have to do, to get this fix? Is it possible to use other plugins to workaround this problem?

          Ulli Hafner added a comment -

          There is no fix yet, so no chance to get it into the LTS release. The fix above (https://github.com/jenkinsci/jenkins/pull/3277) has been reverted since several old plugins rely on the old and broken prototype functionality. Since we have no UI tests for them (and no responsible UI architect in core) I doubt that we ever get rid of this library.

          Ulli Hafner added a comment - There is no fix yet, so no chance to get it into the LTS release. The fix above ( https://github.com/jenkinsci/jenkins/pull/3277 ) has been reverted since several old plugins rely on the old and broken prototype functionality. Since we have no UI tests for them (and no responsible UI architect in core) I doubt that we ever get rid of this library.

          Daniel Beck added a comment -

          drulli If you see "obat", that's Indonesian spam/a spammer. It's OK if they just create issues, but the vandalism elsewhere disrupts more

          Daniel Beck added a comment - drulli If you see "obat", that's Indonesian spam/a spammer. It's OK if they just create issues, but the vandalism elsewhere disrupts more

          Ronny Perinke added a comment -

          It is possible to restore the original / native implementation of an overridden prototype function. It would also be possible to restore whole prototype. Here is an example for a single function. I'm sure you know how to restore whole prototype based on this.

          function getNativeFunction(clazz, func) {
              const frame = document.createElement('iframe');
              frame.style.display = 'none';
              document.body.appendChild(frame);
              const nativeClazz = frame.contentWindow[clazz];
              frame.parentNode.removeChild(frame);
              return nativeClazz.prototype[func];
          }
          
          if (Array.prototype.filter.toString().indexOf('[native code]') === -1) {
              Array.prototype.filter = getNativeFunction('Array', 'filter');
          }
          

          Ronny Perinke added a comment - It is possible to restore the original / native implementation of an overridden prototype function. It would also be possible to restore whole prototype. Here is an example for a single function. I'm sure you know how to restore whole prototype based on this. function getNativeFunction(clazz, func) { const frame = document.createElement( 'iframe' ); frame.style.display = 'none' ; document.body.appendChild(frame); const nativeClazz = frame.contentWindow[clazz]; frame.parentNode.removeChild(frame); return nativeClazz.prototype[func]; } if (Array.prototype.filter.toString().indexOf( '[ native code]' ) === -1) { Array.prototype.filter = getNativeFunction( 'Array' , 'filter' ); }

          Ulli Hafner added a comment -

          I think that we will never get a sufficient test coverage before making this change. Since I found workarounds for my JS libraries I think we can close this issue.

          Ulli Hafner added a comment - I think that we will never get a sufficient test coverage before making this change. Since I found workarounds for my JS libraries I think we can close this issue.

            Unassigned Unassigned
            drulli Ulli Hafner
            Votes:
            1 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: