mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-24 02:31:13 +08:00
fix: 修复 Object 的输出格式
This commit is contained in:
@@ -125,22 +125,26 @@ fn format_result(string_forge: &StringForge, val: JsValue) {
|
||||
}
|
||||
} else if val.is_object() {
|
||||
let obj = unsafe { &*val.as_js_object_ptr() };
|
||||
print!("{{");
|
||||
let count = obj.prop_count() as usize;
|
||||
let mut first = true;
|
||||
for i in 0..count.min(4) {
|
||||
let prop_val = obj.get_inline_prop(i as u8);
|
||||
if prop_val.is_undefined() {
|
||||
continue;
|
||||
if obj.is_function() {
|
||||
println!("[Function]");
|
||||
} else {
|
||||
print!("{{");
|
||||
let count = obj.prop_count() as usize;
|
||||
let mut first = true;
|
||||
for i in 0..count.min(4) {
|
||||
let prop_val = obj.get_inline_prop(i as u8);
|
||||
if prop_val.is_undefined() {
|
||||
continue;
|
||||
}
|
||||
if !first {
|
||||
print!(", ");
|
||||
}
|
||||
first = false;
|
||||
print!("{:?}: ", i);
|
||||
print_value(string_forge, prop_val);
|
||||
}
|
||||
if !first {
|
||||
print!(", ");
|
||||
}
|
||||
first = false;
|
||||
print!("{:?}: ", i);
|
||||
print_value(string_forge, prop_val);
|
||||
println!("}}");
|
||||
}
|
||||
println!("}}");
|
||||
} else if val.is_undefined() {
|
||||
println!("undefined");
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user