From a923c7cc9b74c28e367ff76b3e80ac70b68a4886 Mon Sep 17 00:00:00 2001 From: Roman Dvornov Date: Mon, 30 Oct 2023 02:39:12 +0100 Subject: [PATCH] Use assertions --- src/extensions/inspector.js | 2 +- src/extensions/inspector/props-config.js | 2 +- src/extensions/inspector/view-tree.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/extensions/inspector.js b/src/extensions/inspector.js index 2a75626a..7b908b13 100644 --- a/src/extensions/inspector.js +++ b/src/extensions/inspector.js @@ -278,7 +278,7 @@ export default (host) => { data => data.value.view && data.value.view.skipped ? 'skipped' : false ], content: [ - 'text:value | viewRoot.name or view.config.view | $ + "" = $ ? $ : "ƒn"' // FIXME: `$ + "" = $` is a hack to check value is a string + 'text:value | viewRoot.name or view.config.view | is string ?: "ƒn"' // { // view: 'list', // when: false, // postponed for future releases diff --git a/src/extensions/inspector/props-config.js b/src/extensions/inspector/props-config.js index a7f1d2be..237fe287 100644 --- a/src/extensions/inspector/props-config.js +++ b/src/extensions/inspector/props-config.js @@ -12,7 +12,7 @@ export const propsConfigView = { { view: 'block', className: 'content-section render', - when: 'config | view + "" != view', + when: 'config.view is not string', content: 'source:{ content: config.view + "", syntax: "js" }' }, { diff --git a/src/extensions/inspector/view-tree.js b/src/extensions/inspector/view-tree.js index 54e0a556..357c8cd5 100644 --- a/src/extensions/inspector/view-tree.js +++ b/src/extensions/inspector/view-tree.js @@ -84,7 +84,7 @@ export function viewTree(el, { selectTreeViewLeaf, detailsSidebarLeafExpanded }) data => data.view?.skipped ? 'skipped' : false, 'selected' ], - content: 'text:view.config.view or "#root" | $ + "" = $ ? $ : "ƒn"', // FIXME: `$ + "" = $` is a hack to check value is a string + content: 'text:view.config.view or "#root" | is string ?: "ƒn"', postRender(el_) { requestAnimationFrame(() => { el.querySelector('.sidebar').scrollTop = viewTreeScrollTopBeforeSelect; @@ -100,7 +100,7 @@ export function viewTree(el, { selectTreeViewLeaf, detailsSidebarLeafExpanded }) { view: 'link', className: data => data.view?.skipped ? 'skipped' : false, - data: '{ text: view.config.view or "#root" | $ + "" = $ ? $ : "ƒn", href: false, view, self: $ }', // FIXME: `$ + "" = $` is a hack to check value is a string + data: '{ text: view.config.view or "#root" | is string ?: "ƒn", href: false, view, self: $ }', onClick(_, data) { viewTreeScrollTopBeforeSelect = el.querySelector('.sidebar')?.scrollTop || 0; selectTreeViewLeaf(data.self);