diff options
author | Wojtek Kosior <koszko@koszko.org> | 2022-02-09 18:29:49 +0100 |
---|---|---|
committer | Wojtek Kosior <koszko@koszko.org> | 2022-02-09 18:29:49 +0100 |
commit | 3d6ffa57e8a901bd61c2d95fbb6d1ca16d811898 (patch) | |
tree | 71878aacd7dae3dab9150f3f34f8256f92c95480 /html/item_preview.js | |
parent | 1c65dd5ca24052ccf9a92939eecd0966c9635c50 (diff) | |
download | browser-extension-3d6ffa57e8a901bd61c2d95fbb6d1ca16d811898.tar.gz browser-extension-3d6ffa57e8a901bd61c2d95fbb6d1ca16d811898.zip |
make resource dependency specifier an object
Diffstat (limited to 'html/item_preview.js')
-rw-r--r-- | html/item_preview.js | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/html/item_preview.js b/html/item_preview.js index bd4fd68..1da9492 100644 --- a/html/item_preview.js +++ b/html/item_preview.js @@ -82,7 +82,10 @@ function resource_preview(resource, preview_object, link_cb=make_file_link) { preview_object.source_name.innerText = resource.source_name; [...preview_object.dependencies.childNodes].forEach(n => n.remove()); - populate_list(preview_object.dependencies, resource.dependencies); + + const deps_refs = resource.dependencies || []; + populate_list(preview_object.dependencies, + deps_refs.map(res_ref => res_ref.identifier)); const link_maker = file_ref => link_cb(preview_object, file_ref); @@ -109,7 +112,8 @@ function mapping_preview(mapping, preview_object, link_cb=make_file_link) { preview_object.source_name.innerText = mapping.source_name; [...preview_object.payloads.childNodes].forEach(n => n.remove()); - for (const [pattern, payload] of Object.entries(mapping.payloads).sort()) { + const payload_entries = Object.entries(mapping.payloads || {}).sort(); + for (const [pattern, payload] of payload_entries) { /* We use a non-breaking space because normal space would be ignored. */ const [nbsp, rarrow] = [160, 0x2192].map(n => String.fromCodePoint(n)); const texts = [`${pattern}${nbsp}`, `${rarrow} ${payload.identifier}`]; |