replace deprecated "for each...in" syntax (#3753)

Co-authored-by: Antonin Delpeuch <antonin@delpeuch.eu>
This commit is contained in:
Lu Liu 2021-03-18 20:47:31 +08:00 committed by GitHub
parent 0f024d833e
commit deae864bca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -592,7 +592,11 @@ function process(path, request, response) {
var output = response.getWriter(); var output = response.getWriter();
try { try {
var paths = ClientSideResourceManager.getPaths(lastSegment + "/scripts"); var paths = ClientSideResourceManager.getPaths(lastSegment + "/scripts");
for each (var qualifiedPath in paths) { for (var key in paths) {
if (!paths.hasOwnProperty(key)) {
continue;
}
var qualifiedPath = paths[key];
var input = null; var input = null;
try { try {
var url = qualifiedPath.module.getResource(qualifiedPath.path); var url = qualifiedPath.module.getResource(qualifiedPath.path);
@ -637,9 +641,12 @@ function process(path, request, response) {
var styles = ClientSideResourceManager.getPaths(lastSegment + "/styles"); var styles = ClientSideResourceManager.getPaths(lastSegment + "/styles");
var styleInjection = []; var styleInjection = [];
for each (var qualifiedPath in styles) { for (var key in styles) {
styleInjection.push( if (styles.hasOwnProperty(key)) {
'<link type="text/css" rel="stylesheet" href="' + qualifiedPath.fullPath.substring(1) + '" />'); var qualifiedPath = styles[key];
styleInjection.push(
'<link type="text/css" rel="stylesheet" href="' + qualifiedPath.fullPath.substring(1) + '" />');
}
} }
context.styleInjection = styleInjection.join("\n"); context.styleInjection = styleInjection.join("\n");
@ -648,9 +655,12 @@ function process(path, request, response) {
} else { } else {
var scripts = ClientSideResourceManager.getPaths(lastSegment + "/scripts"); var scripts = ClientSideResourceManager.getPaths(lastSegment + "/scripts");
var scriptInjection = []; var scriptInjection = [];
for each (var qualifiedPath in scripts) { for (var key in scripts) {
scriptInjection.push( if (scripts.hasOwnProperty(key)) {
'<script type="text/javascript" src="' + qualifiedPath.fullPath.substring(1) + '"></script>'); var qualifiedPath = scripts[key];
scriptInjection.push(
'<script type="text/javascript" src="' + qualifiedPath.fullPath.substring(1) + '"></script>');
}
} }
context.scriptInjection = scriptInjection.join("\n"); context.scriptInjection = scriptInjection.join("\n");
} }
@ -659,11 +669,19 @@ function process(path, request, response) {
var encodings = []; var encodings = [];
var sortedCharsetMap = Packages.java.nio.charset.Charset.availableCharsets(); var sortedCharsetMap = Packages.java.nio.charset.Charset.availableCharsets();
for each (var code in sortedCharsetMap.keySet().toArray()) { var keySetArray = sortedCharsetMap.keySet().toArray();
for (var key in keySetArray) {
if (!keySetArray.hasOwnProperty(key)) {
continue;
}
var code = keySetArray[key];
var charset = sortedCharsetMap.get(code); var charset = sortedCharsetMap.get(code);
var aliasesArray = charset.aliases().toArray();
var aliases = []; var aliases = [];
for each (var alias in charset.aliases().toArray()) { for (var key1 in aliasesArray) {
aliases.push(alias); if (aliasesArray.hasOwnProperty(key1)) {
aliases.push(aliasesArray[key1]);
}
} }
encodings.push({ encodings.push({