fix refactor value explorer

This commit is contained in:
Dmitry Vasilev
2023-07-31 23:32:34 +03:00
parent c006aae380
commit e79e8cd704
3 changed files with 12 additions and 6 deletions

View File

@@ -6,7 +6,7 @@
import {el, stringify, scrollIntoViewIfNeeded} from './domutils.js'
import {with_code_execution} from '../index.js'
import {header, is_expandable} from '../value_explorer_utils.js'
import {header, is_expandable, displayed_entries} from '../value_explorer_utils.js'
const get_path = (o, path) => {
@@ -236,7 +236,13 @@ export class ValueExplorer {
this.set_active(this.current_path, true)
}
render_value_explorer_node(key, value, path, node_data) {
render_value_explorer_node(...args) {
return with_code_execution(() => {
return this.do_render_value_explorer_node(...args)
})
}
do_render_value_explorer_node(key, value, path, node_data) {
const is_exp = is_expandable(value)
const is_expanded = is_exp && node_data.is_expanded

View File

@@ -291,6 +291,8 @@ export const exec = (cmd, ...args) => {
}
// Wrap with_code_execution, because rendering values can trigger execution
// of code by toString() and toJSON() methods
with_code_execution(() => {
apply_side_effects(state, nextstate, cmd, ui);

View File

@@ -22,15 +22,13 @@ const isDate = object =>
const toJSON_safe = object => {
try {
return with_code_execution(() => {
return object.toJSON()
})
return object.toJSON()
} catch(e) {
return object
}
}
const displayed_entries = object => {
export const displayed_entries = object => {
if(object == null || typeof(object) != 'object') {
return []
} else if((object[Symbol.toStringTag]) == 'Module') {