| 293 | } |
| 294 | |
| 295 | function appendProperties(obj, ...keys) { |
| 296 | const key = keys.pop(); |
| 297 | const value = objValue(obj, ...keys); |
| 298 | const getter = value.__lookupGetter__(key); |
| 299 | const $key = tag("c-key", { |
| 300 | textContent: key + ":", |
| 301 | }); |
| 302 | let $val; |
| 303 | |
| 304 | if (getter) { |
| 305 | $val = tag("c-span", { |
| 306 | style: { |
| 307 | textDecoration: "underline", |
| 308 | color: "#39f", |
| 309 | margin: "0 10px", |
| 310 | }, |
| 311 | textContent: `...`, |
| 312 | onclick() { |
| 313 | const $val = getVal(value[key]); |
| 314 | this.parentElement.replaceChild($val, this); |
| 315 | }, |
| 316 | }); |
| 317 | } else { |
| 318 | $val = getVal(value[key]); |
| 319 | } |
| 320 | |
| 321 | return tag("c-line", { |
| 322 | children: [$key, $val], |
| 323 | }); |
| 324 | |
| 325 | function getVal(val) { |
| 326 | const type = typeof val; |
| 327 | const $val = getElement(type); |
| 328 | if (type === "object" && val !== null) { |
| 329 | $val.append(...getBody(obj, ...keys, key)); |
| 330 | } else { |
| 331 | if (type === "function") { |
| 332 | val = parseFunction(val); |
| 333 | } |
| 334 | $val.textContent = val + ""; |
| 335 | } |
| 336 | return $val; |
| 337 | } |
| 338 | } |
| 339 | |
| 340 | function objValue(obj, ...keys) { |
| 341 | return keys.reduce((acc, key) => acc[key], obj); |