mirror of https://github.com/vuejs/vitepress
fix(client): resolve SVG links when prefetching (#5442)
parent
f1bcc0d971
commit
6500851eaa
@ -0,0 +1 @@
|
||||
# HTML link destination
|
||||
@ -0,0 +1,15 @@
|
||||
---
|
||||
sidebar: false
|
||||
outline: false
|
||||
---
|
||||
|
||||
# Link prefetching
|
||||
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="400" height="150">
|
||||
<a href="./svg.html"><text x="10" y="25">SVG link</text></a>
|
||||
<a href="./svg.html#section"><text x="10" y="50">Same page, another hash</text></a>
|
||||
<a xlink:href="./xlink.html"><text x="10" y="75">SVG xlink</text></a>
|
||||
<a href="./new-tab.html" target="_blank"><text x="10" y="100">New tab</text></a>
|
||||
</svg>
|
||||
|
||||
[HTML link](./html.md)
|
||||
@ -0,0 +1 @@
|
||||
# New tab destination
|
||||
@ -0,0 +1,43 @@
|
||||
test.runIf(process.env.VITE_TEST_BUILD)(
|
||||
'prefetches SVG links without errors and respects new-tab targets',
|
||||
async () => {
|
||||
const errors: string[] = []
|
||||
const onPageError = (error: Error) => errors.push(error.message)
|
||||
page.on('pageerror', onPageError)
|
||||
|
||||
try {
|
||||
await goto('/prefetch/')
|
||||
|
||||
await expect
|
||||
.poll(
|
||||
async () => ({
|
||||
errors,
|
||||
pages: await page
|
||||
.locator('link[rel="prefetch"]')
|
||||
.evaluateAll((links) =>
|
||||
links
|
||||
.map(
|
||||
(link) =>
|
||||
link
|
||||
.getAttribute('href')
|
||||
?.match(/prefetch_(.*?)\.md\./)?.[1]
|
||||
)
|
||||
.filter(Boolean)
|
||||
.sort()
|
||||
)
|
||||
}),
|
||||
{ timeout: 10_000 }
|
||||
)
|
||||
.toEqual({ errors: [], pages: ['html', 'svg', 'xlink'] })
|
||||
|
||||
await page.locator('svg a[href="./svg.html"]').click()
|
||||
await page.waitForSelector('h1', { state: 'visible' })
|
||||
await expect
|
||||
.poll(() => page.locator('h1').textContent())
|
||||
.toContain('SVG link destination')
|
||||
expect(errors).toEqual([])
|
||||
} finally {
|
||||
page.off('pageerror', onPageError)
|
||||
}
|
||||
}
|
||||
)
|
||||
@ -0,0 +1,3 @@
|
||||
# SVG link destination
|
||||
|
||||
## Section
|
||||
@ -0,0 +1 @@
|
||||
# SVG xlink destination
|
||||
Loading…
Reference in new issue