golden-path-check finds its manifest from its own script, so it answers when embedded
It derived the tree root from the page path. Embedded on a host page (/embed-test, a partner site) the page is the host's, so the manifest fetch missed and it rendered an empty checklist. It now uses bundleTreeRoot() (the bundle's own script URL, captured when the script starts), and falls back to the page path only when that is unavailable, as on the dev server.
This commit is contained in:
parent
311b5c24a0
commit
18eabae1ca
1 changed files with 7 additions and 1 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
|
import { bundleTreeRoot } from '@map/utils/embedBase.js'
|
||||||
/**
|
/**
|
||||||
* golden-path-check.vue — the capability-1 single-element SELF-TEST of the golden path.
|
* golden-path-check.vue — the capability-1 single-element SELF-TEST of the golden path.
|
||||||
*
|
*
|
||||||
|
|
@ -45,10 +46,15 @@ const manifest = ref(null)
|
||||||
* <tree>/<bundle>/<profile>/index.html
|
* <tree>/<bundle>/<profile>/index.html
|
||||||
* so the manifest sits three levels up. A host embedding the element directly can override with
|
* so the manifest sits three levels up. A host embedding the element directly can override with
|
||||||
* the `tree-base` ATTRIBUTE (<golden-path-check tree-base="https://host/doxa-maps">). Falls back
|
* the `tree-base` ATTRIBUTE (<golden-path-check tree-base="https://host/doxa-maps">). Falls back
|
||||||
* to deriving it from location.pathname so a plain drop still resolves.
|
* to the bundle's own script URL (bundleTreeRoot), then to location.pathname for the dev server.
|
||||||
*/
|
*/
|
||||||
const treeBase = computed(() => {
|
const treeBase = computed(() => {
|
||||||
if (props.treeBase) return props.treeBase.replace(/\/+$/, '')
|
if (props.treeBase) return props.treeBase.replace(/\/+$/, '')
|
||||||
|
// The bundle's OWN script URL first. Embedded on a host page (/embed-test, a partner site) the
|
||||||
|
// DOCUMENT is the host's, so the page path below points at the host and the manifest fetch misses,
|
||||||
|
// which rendered an empty checklist. bundleTreeRoot() reads <tree>/<bundle>/<bundle>.js.
|
||||||
|
const fromScript = bundleTreeRoot()
|
||||||
|
if (fromScript) return fromScript.replace(/\/+$/, '')
|
||||||
if (typeof location === 'undefined') return '.'
|
if (typeof location === 'undefined') return '.'
|
||||||
const parts = location.pathname.split('/').filter(Boolean)
|
const parts = location.pathname.split('/').filter(Boolean)
|
||||||
// drop index.html + <profile> + <bundle> when they are present
|
// drop index.html + <profile> + <bundle> when they are present
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue