Skip to content

Commit

Permalink
Merge branch 'master' into flabrie-patch-3
Browse files Browse the repository at this point in the history
* master:
  Bump org.jenkins-ci.plugins:display-url-api from 2.3.9 to 2.200.vb_9327d658781 (jenkinsci#8536)
  Update dependency postcss-scss to v4.0.9 (jenkinsci#8541)
  Update dependency postcss to v8.4.31 (jenkinsci#8540)
  Update dependency node to v18.18.0 (jenkinsci#8537)
  [JENKINS-70906] Remove prototype from core (jenkinsci#7781)
  • Loading branch information
Francis Labrie committed Oct 2, 2023
2 parents 3ac0b5c + a7befec commit 651f897
Show file tree
Hide file tree
Showing 15 changed files with 21 additions and 6,370 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,9 @@ function confirmAndRevokeAllSelected(button) {
selectedValues.push({ userId: userId, uuid: uuid });
}

// TODO simplify when Prototype.js is removed

fetch(url, {
method: "post",
body: Object.toJSON
? Object.toJSON({ values: selectedValues })
: JSON.stringify({ values: selectedValues }),
body: JSON.stringify({ values: selectedValues }),
headers: crumb.wrap({ "Content-Type": "application/json" }),
}).then(() => window.location.reload());
},
Expand Down
4 changes: 0 additions & 4 deletions core/src/main/resources/lib/layout/layout.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,6 @@ THE SOFTWARE.
<link rel="mask-icon" href="${resURL}/mask-icon.svg" color="#191717" />
<meta name="theme-color" content="#ffffff" />

<l:userExperimentalFlag var="removePrototype" flagClassName="jenkins.model.experimentalflags.RemovePrototypeUserExperimentalFlag" />
<j:if test="${!removePrototype}">
<script src="${resURL}/scripts/prototype.js" type="text/javascript"/>
</j:if>
<script src="${resURL}/scripts/behavior.js" type="text/javascript"/>

<st:adjunct includes="org.kohsuke.stapler.bind"/>
Expand Down
2 changes: 1 addition & 1 deletion test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ THE SOFTWARE.
<!-- RequireUpperBoundDeps via mailer and junit -->
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>display-url-api</artifactId>
<version>2.3.9</version>
<version>2.200.vb_9327d658781</version>
</dependency>
<dependency>
<!-- requireUpperBoundDeps via matrix-project and junit -->
Expand Down
42 changes: 0 additions & 42 deletions test/src/test/java/hudson/ExceptionTest.java

This file was deleted.

This file was deleted.

11 changes: 2 additions & 9 deletions test/src/test/resources/lib/form/JSON.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,7 @@ if (typeof JSON=="undefined") {
return String.evalJSON(str);
},
stringify : function (obj) {
// TODO simplify when Prototype.js is removed
if (Object.toJSON) {
// Prototype.js
return Object.toJSON(obj);
} else {
// Standard
return JSON.stringify(obj);
}
return JSON.stringify(obj);
}
};
}
}
1 change: 0 additions & 1 deletion war/.eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ jsbundles

# External scripts
src/main/webapp/scripts/yui
src/main/webapp/scripts/prototype.js
src/main/js/plugin-setup-wizard/bootstrap-detached.js
1 change: 0 additions & 1 deletion war/.prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ node/
# libraries / external deps / generated files
src/main/js/plugin-setup-wizard/bootstrap-detached.js
src/main/webapp/scripts/yui
src/main/webapp/scripts/prototype.js
src/main/webapp/jsbundles/
src/main/scss/_bootstrap.scss

Expand Down
4 changes: 2 additions & 2 deletions war/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
"eslint-config-prettier": "9.0.0",
"handlebars-loader": "1.7.3",
"mini-css-extract-plugin": "2.7.6",
"postcss": "8.4.30",
"postcss": "8.4.31",
"postcss-loader": "7.3.3",
"postcss-preset-env": "9.1.4",
"postcss-scss": "4.0.8",
"postcss-scss": "4.0.9",
"prettier": "3.0.3",
"sass": "1.68.0",
"sass-loader": "13.3.2",
Expand Down
2 changes: 1 addition & 1 deletion war/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ THE SOFTWARE.
<host>localhost</host>
<!-- HTTP listener port -->
<port>8080</port>
<node.version>18.17.1</node.version>
<node.version>18.18.0</node.version>
<!-- frontend-maven-plugin will install this Yarn version as bootstrap, then hand over control to Yarn Berry. -->
<yarn.version>1.22.19</yarn.version>
<!-- maven-antrun-plugin will download this Yarn version. -->
Expand Down
40 changes: 2 additions & 38 deletions war/src/main/js/util/jenkins.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,42 +17,6 @@ jenkins.baseUrl = function () {
return u;
};

// awful hack to get around JSONifying things with Prototype taking over wrong. ugh. Prototype is the worst.
jenkins.stringify = function (o) {
if (Array.prototype.toJSON) {
// Prototype f's this up something bad
var protoJSON = {
a: Array.prototype.toJSON,
o: Object.prototype.toJSON,
h: Hash.prototype.toJSON,
s: String.prototype.toJSON,
};
try {
delete Array.prototype.toJSON;
delete Object.prototype.toJSON;
delete Hash.prototype.toJSON;
delete String.prototype.toJSON;

return JSON.stringify(o);
} finally {
if (protoJSON.a) {
Array.prototype.toJSON = protoJSON.a;
}
if (protoJSON.o) {
Object.prototype.toJSON = protoJSON.o;
}
if (protoJSON.h) {
Hash.prototype.toJSON = protoJSON.h;
}
if (protoJSON.s) {
String.prototype.toJSON = protoJSON.s;
}
}
} else {
return JSON.stringify(o);
}
};

/**
* redirect
*/
Expand Down Expand Up @@ -82,7 +46,7 @@ jenkins.get = function (url, success, options) {
};

/**
* Jenkins AJAX POST callback, formats data as a JSON object post (note: works around prototype.js ugliness using stringify() above)
* Jenkins AJAX POST callback, formats data as a JSON object post
* If last parameter is an object, will be extended to jQuery options (e.g. pass { error: function() ... } to handle errors)
*/
jenkins.post = function (url, data, success, options) {
Expand Down Expand Up @@ -110,7 +74,7 @@ jenkins.post = function (url, data, success, options) {
formBody = $.extend({}, formBody);
formBody[crumb.fieldName] = crumb.value;
}
formBody = jenkins.stringify(formBody);
formBody = JSON.stringify(formBody);
}

var args = {
Expand Down
30 changes: 2 additions & 28 deletions war/src/main/webapp/scripts/hudson-behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -2200,6 +2200,7 @@ function encode(str) {
// when there are multiple form elements of the same name,
// this method returns the input field of the given name that pairs up
// with the specified 'base' input element.
// eslint-disable-next-line no-unused-vars
function findMatchingFormInput(base, name) {
// find the FORM element that owns us
var f = base.closest("form");
Expand Down Expand Up @@ -2232,17 +2233,6 @@ function findMatchingFormInput(base, name) {
return null; // not found
}

// TODO remove when Prototype.js is removed
if (typeof Form === "object") {
/** @deprecated For backward compatibility only; use {@link findMatchingFormInput} instead. */
Form.findMatchingInput = function (base, name) {
console.warn(
"Deprecated call to Form.findMatchingInput detected; use findMatchingFormInput instead.",
);
return findMatchingFormInput(base, name);
};
}

// eslint-disable-next-line no-unused-vars
function toQueryString(params) {
var query = "";
Expand Down Expand Up @@ -2627,14 +2617,7 @@ function buildFormTree(form) {
}
}

// TODO simplify when Prototype.js is removed
if (Object.toJSON) {
// Prototype.js
jsonElement.value = Object.toJSON(form.formDom);
} else {
// Standard
jsonElement.value = JSON.stringify(form.formDom);
}
jsonElement.value = JSON.stringify(form.formDom);

// clean up
for (i = 0; i < doms.length; i++) {
Expand Down Expand Up @@ -2803,15 +2786,6 @@ function createComboBox(idOrField, valueFunction) {
}
}

// Exception in code during the AJAX processing should be reported,
// so that our users can find them more easily.
// TODO remove when Prototype.js is removed
if (typeof Ajax === "object" && Ajax.Request) {
Ajax.Request.prototype.dispatchException = function (e) {
throw e;
};
}

// event callback when layouts/visibility are updated and elements might have moved around
var layoutUpdateCallback = {
callbacks: [],
Expand Down
Loading

0 comments on commit 651f897

Please sign in to comment.