Skip to content

Commit

Permalink
[CfgEditor] Check properties existence in loop (#1685)
Browse files Browse the repository at this point in the history
* [CfgEditor] Check properties existence in loop

This commit checks properties' existence in for loop.
* Update media/CfgEditor/index.js

Co-authored-by: Seungho Henry Park <[email protected]>
ONE-vscode-DCO-1.0-Signed-off-by: Dayoung Lee <[email protected]>
  • Loading branch information
dayo09 and shs-park authored Sep 26, 2023
1 parent 7b015c2 commit 4ba5ba1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
7 changes: 4 additions & 3 deletions media/CfgEditor/displaycfg.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,10 @@ export function displayCfgToEditor(cfg) {
oneOptimize?.["output_path"]
);
for (const optName in oneOptimizationList) {
document.getElementById("checkboxOptimize" + optName).checked = cfgBoolean(
oneOptimize?.[optName]
);
if (Object.prototype.hasOwnProperty.call(oneOptimizationList, optName)) {
document.getElementById("checkboxOptimize" + optName).checked =
cfgBoolean(oneOptimize?.[optName]);
}
}

const oneQuantize = cfg["one-quantize"];
Expand Down
17 changes: 11 additions & 6 deletions media/CfgEditor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,9 @@ function registerOptimizeOptions() {
});

for (const optName in oneOptimizationList) {
if (!Object.prototype.hasOwnProperty.call(oneOptimizationList, optName)) {
continue;
}
let row = document.createElement("vscode-data-grid-row");

let cellSwitch = document.createElement("vscode-data-grid-cell");
Expand All @@ -370,12 +373,14 @@ function registerOptimizeOptions() {
}

for (const optName in oneOptimizationList) {
document
.getElementById("checkboxOptimize" + optName)
.addEventListener("click", function () {
updateOptimize();
applyUpdates();
});
if (Object.prototype.hasOwnProperty.call(oneOptimizationList, optName)) {
document
.getElementById("checkboxOptimize" + optName)
.addEventListener("click", function () {
updateOptimize();
applyUpdates();
});
}
}
}

Expand Down
10 changes: 6 additions & 4 deletions media/CfgEditor/updateContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,12 @@ export function updateOptimize() {
);

for (const optName in oneOptimizationList) {
content += iniKeyValueString(
optName,
document.getElementById("checkboxOptimize" + optName).checked
);
if (Object.prototype.hasOwnProperty.call(oneOptimizationList, optName)) {
content += iniKeyValueString(
optName,
document.getElementById("checkboxOptimize" + optName).checked
);
}
}

postMessageToVsCode({
Expand Down

0 comments on commit 4ba5ba1

Please sign in to comment.