Skip to content

Commit

Permalink
[IMP] devtools: show objects class name and add special extension cases
Browse files Browse the repository at this point in the history
This commit ensures that class names are displayed for non generic
objects and extensions of generic classes will have custom display for
their content.
  • Loading branch information
juliusc2066 authored and ged-odoo committed Oct 11, 2024
1 parent 15c2604 commit 04c2808
Showing 1 changed file with 27 additions and 16 deletions.
43 changes: 27 additions & 16 deletions tools/devtools/src/page_scripts/owl_devtools_global_hook.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,23 +109,34 @@
object(obj) {
const result = [];
let length = 0;
for (const [key, value] of Object.entries(obj)) {
if (length > 25) {
result.push("...");
break;
if (obj instanceof String) {
result[0] = `'${obj.toString()}'`;
} else if (obj instanceof Array) {
return `${obj.constructor.name} ${this.array([...obj])}`;
} else if (obj instanceof Number) {
result[0] = obj.toString();
} else {
for (const [key, value] of Object.entries(obj)) {
if (length > 25) {
result.push("...");
break;
}
const element = key + ": " + this.serializeItem(value);
length += element.length;
result.push(element);
}
const element = key + ": " + this.serializeItem(value);
length += element.length;
result.push(element);
}
for (const key of Object.getOwnPropertySymbols(obj)) {
if (length > 25) {
result.push("...");
break;
for (const key of Object.getOwnPropertySymbols(obj)) {
if (length > 25) {
result.push("...");
break;
}
const element = key.toString() + ": " + this.serializeItem(obj[key]);
length += element.length;
result.push(element);
}
const element = key.toString() + ": " + this.serializeItem(obj[key]);
length += element.length;
result.push(element);
}
if (obj.constructor.name !== "Object") {
return obj.constructor.name + " {" + result.join(", ") + "}";
}
return "{" + result.join(", ") + "}";
},
Expand Down Expand Up @@ -823,7 +834,7 @@
child.contentType = "set";
child.hasChildren = true;
break;
case obj instanceof Array:
case obj.constructor.name === "Array":
child.contentType = "array";
child.hasChildren = obj.length > 0;
break;
Expand Down

0 comments on commit 04c2808

Please sign in to comment.