• Icon: Epic Epic
    • Resolution: Unresolved
    • Icon: Major Major
    • core
    • None
    • Remove Prototype

      Jenkins core currently uses Prototype 1.7, released on November 15, 2010. The latest version is Prototype 1.7.3, released on September 22, 2015. When an attempt was made to upgrade to 1.7.3 in 2018 in JENKINS-49319, the change had to be reverted. Since this library has been unmaintained for the past 8 years, we ought to eliminate our dependency on it in favor of modern JavaScript APIs. Once core no longer depends on this API, it should be investigated how this old library can be disabled/removed by default, enabled/present only for the (legacy) plugins that still require it.

          [JENKINS-70906] Remove Prototype

          Basil Crow added a comment -

          judovana You could start by opening PRs for any of the hasClassName / addClassName tickets. They are the easiest to fix, since the replacement is trivial, e.g.:

          diff --git a/core/src/main/resources/hudson/PluginManager/_table.js b/core/src/main/resources/hudson/PluginManager/_table.js
          index 4ce767a279..b9a272c755 100644
          --- a/core/src/main/resources/hudson/PluginManager/_table.js
          +++ b/core/src/main/resources/hudson/PluginManager/_table.js
          @@ -9,13 +9,13 @@ Behaviour.specify("#filter-box", "_table", 0, function (e) {
                 .concat(document.getElementsBySelector("TR.unavailable"));
               var anyVisible = false;
               for (var i = 0; i < items.length; i++) {
          -      if (
          -        (filterParts.length < 1 || filter.length < 2) &&
          -        items[i].hasClassName("hidden-by-default")
          -      ) {
          -        items[i].addClassName("jenkins-hidden");
          -        continue;
          -      }
          +      if (
          +        (filterParts.length < 1 || filter.length < 2) &&
          +        items[i].classList.contains("hidden-by-default")
          +      ) {
          +        items[i].classList.add("jenkins-hidden");
          +        continue;
          +      }
                 var makeVisible = true;
           
                 var pluginId = items[i].getAttribute("data-plugin-id");
          

          When filing the PR and filling out the Testing Done section, try exercising that code path in your browser and setting a breakpoint on the changed lines in the JavaScript debugger to ensure the new code works the same way as the old code.

          Another way to help would be to work on the Ajax.Request tickets. The code for these is harder to write, but Tim has already written much of it in https://github.com/jenkinsci/jenkins/pull/7781 pending testing. So to fix one of those tickets, find the code in Tim's PR, extract it into a new PR, and test as I described above. If it works, then that PR can be merged and Tim's draft PR can shrink. The idea is that as pieces are tested and merged, Tim's draft PR would shrink down to zero eventually.

          Basil Crow added a comment - judovana You could start by opening PRs for any of the hasClassName / addClassName tickets. They are the easiest to fix, since the replacement is trivial, e.g.: diff --git a/core/src/main/resources/hudson/PluginManager/_table.js b/core/src/main/resources/hudson/PluginManager/_table.js index 4ce767a279..b9a272c755 100644 --- a/core/src/main/resources/hudson/PluginManager/_table.js +++ b/core/src/main/resources/hudson/PluginManager/_table.js @@ -9,13 +9,13 @@ Behaviour.specify( "#filter-box" , "_table" , 0, function (e) { .concat(document.getElementsBySelector( "TR.unavailable" )); var anyVisible = false ; for ( var i = 0; i < items.length; i++) { - if ( - (filterParts.length < 1 || filter.length < 2) && - items[i].hasClassName( "hidden-by- default " ) - ) { - items[i].addClassName( "jenkins-hidden" ); - continue ; - } + if ( + (filterParts.length < 1 || filter.length < 2) && + items[i].classList.contains( "hidden-by- default " ) + ) { + items[i].classList.add( "jenkins-hidden" ); + continue ; + } var makeVisible = true ; var pluginId = items[i].getAttribute( "data-plugin-id" ); When filing the PR and filling out the Testing Done section, try exercising that code path in your browser and setting a breakpoint on the changed lines in the JavaScript debugger to ensure the new code works the same way as the old code. Another way to help would be to work on the Ajax.Request tickets. The code for these is harder to write, but Tim has already written much of it in https://github.com/jenkinsci/jenkins/pull/7781 pending testing. So to fix one of those tickets, find the code in Tim's PR, extract it into a new PR, and test as I described above. If it works, then that PR can be merged and Tim's draft PR can shrink. The idea is that as pieces are tested and merged, Tim's draft PR would shrink down to zero eventually.

          jiri vanek added a comment -

          thanx a lot, will try.

          jiri vanek added a comment - thanx a lot, will try.

          Ulli Hafner added a comment -

          Should the usages of makeStaplerProxy in bind.js already work? I'm getting the following error in 2.404:

          calhost/:1 Uncaught (in promise) SyntaxError: "undefined" is not valid JSON
              at JSON.parse (<anonymous>)
              at redraw (trend-chart.js:96:44)
              at trend-chart.js:132:13
              at bind.js:52:33
          

          Ulli Hafner added a comment - Should the usages of makeStaplerProxy in bind.js already work? I'm getting the following error in 2.404: calhost/:1 Uncaught (in promise) SyntaxError: "undefined" is not valid JSON at JSON.parse (<anonymous>) at redraw (trend-chart.js:96:44) at trend-chart.js:132:13 at bind.js:52:33

          Ulli Hafner added a comment -

          Ah, seems that this is broken anyway in 2.404 when I load the trend charts.

          Ulli Hafner added a comment - Ah, seems that this is broken anyway in 2.404 when I load the trend charts.

          Basil Crow added a comment -

          I have added a link to a tracking spreadsheet for plugins.

          Basil Crow added a comment - I have added a link to a tracking spreadsheet for plugins.

          Ulli Hafner added a comment -

          Thanks for making this possible! I tried the new user property and all of my UI contributing plugins are still working without any problems!

          I also created a new PR https://github.com/jenkinsci/data-tables-api-plugin/pull/356 that enables the auto-save feature of the DataTables component and it looks like the removal of Prototype fixed that issue finally (DataTables serializes the state with JSON, this did not work before).

          Ulli Hafner added a comment - Thanks for making this possible! I tried the new user property and all of my UI contributing plugins are still working without any problems! I also created a new PR https://github.com/jenkinsci/data-tables-api-plugin/pull/356 that enables the auto-save feature of the DataTables component and it looks like the removal of Prototype fixed that issue finally (DataTables serializes the state with JSON, this did not work before).

          Ulli Hafner added a comment -

          And another issue that has been resolved by deactivating Prototype.js: https://github.com/apache/echarts/issues/18367

          Ulli Hafner added a comment - And another issue that has been resolved by deactivating Prototype.js: https://github.com/apache/echarts/issues/18367

          David Aldrich added a comment -

          With Jenkins 2.410 and with experiment Remove Prototype.js enabled, when I use the Snippet Generator I see the following unexpected behaviour:

          Button Generate Pipeline Script is shown in the UI, but when I hover over the button it disappears.

          This seems to happen irrespective of which Sample Step is selected.

          I guess this is a bug?

          David Aldrich added a comment - With Jenkins 2.410 and with experiment Remove Prototype.js enabled, when I use the Snippet Generator I see the following unexpected behaviour: Button Generate Pipeline Script is shown in the UI, but when I hover over the button it disappears. This seems to happen irrespective of which Sample Step is selected. I guess this is a bug?

          Basil Crow added a comment -

          davida2009 A pull request was filed to resolve this issue on May 11, 2023. That pull request was approved by a maintainer with write access on May 15, 2023. This pull request remains unmerged and unreleased 1 month and 8 days after it was filed.

          Basil Crow added a comment - davida2009 A pull request was filed to resolve this issue on May 11, 2023. That pull request was approved by a maintainer with write access on May 15, 2023. This pull request remains unmerged and unreleased 1 month and 8 days after it was filed.

          Kalle Niemitalo added a comment - - edited

          Should jenkins.views.PartialHeader.compatibilityHeaderVersion be incremented because of the removal of Prototype? (JEP-234, PartialHeader.java, core PR#5909 comment.) The change is to "core resources (images, CSS, JS, etc.)" but not specifically to the header API. I guess it's better not to increment because such a change would break compatibility with custom headers that never used Prototype, which may be most of them.

          Kalle Niemitalo added a comment - - edited Should jenkins.views.PartialHeader.compatibilityHeaderVersion be incremented because of the removal of Prototype? ( JEP-234 , PartialHeader.java , core PR#5909 comment .) The change is to "core resources (images, CSS, JS, etc.)" but not specifically to the header API. I guess it's better not to increment because such a change would break compatibility with custom headers that never used Prototype, which may be most of them.

            Unassigned Unassigned
            basil Basil Crow
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated: