mirror of
https://github.com/withastro/astro.git
synced 2025-04-07 23:41:43 -05:00
Fix resolution of Astro.resolve in nested components (#1213)
* Fix resolution of Astro.resolve in nested components Components were previously tested, however nested folders were not. * Adds a changeset
This commit is contained in:
parent
d0e7fcfc06
commit
9482fadeb8
5 changed files with 14 additions and 5 deletions
5
.changeset/violet-crabs-deny.md
Normal file
5
.changeset/violet-crabs-deny.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'astro': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Makes sure Astro.resolve works in nested component folders
|
|
@ -169,10 +169,6 @@ async function __render(props, ...children) {
|
||||||
value: (props[__astroInternal] && props[__astroInternal].isPage) || false,
|
value: (props[__astroInternal] && props[__astroInternal].isPage) || false,
|
||||||
enumerable: true
|
enumerable: true
|
||||||
},
|
},
|
||||||
resolve: {
|
|
||||||
value: (props[__astroContext] && props[__astroContext].resolve) || {},
|
|
||||||
enumerable: true
|
|
||||||
},
|
|
||||||
request: {
|
request: {
|
||||||
value: (props[__astroContext] && props[__astroContext].request) || {},
|
value: (props[__astroContext] && props[__astroContext].request) || {},
|
||||||
enumerable: true
|
enumerable: true
|
||||||
|
@ -201,7 +197,6 @@ export async function __renderPage({request, children, props, css}) {
|
||||||
value: {
|
value: {
|
||||||
pageCSS: css,
|
pageCSS: css,
|
||||||
request,
|
request,
|
||||||
resolve: __TopLevelAstro.resolve,
|
|
||||||
createAstroRootUID(seed) { return seed + astroRootUIDCounter++; },
|
createAstroRootUID(seed) { return seed + astroRootUIDCounter++; },
|
||||||
},
|
},
|
||||||
writable: false,
|
writable: false,
|
||||||
|
|
|
@ -48,6 +48,7 @@ Global('Astro.resolve in development', async (context) => {
|
||||||
const html = result.contents;
|
const html = result.contents;
|
||||||
const $ = doc(html);
|
const $ = doc(html);
|
||||||
assert.equal($('img').attr('src'), '/_astro/src/images/penguin.png');
|
assert.equal($('img').attr('src'), '/_astro/src/images/penguin.png');
|
||||||
|
assert.equal($('#inner-child img').attr('src'), '/_astro/src/components/nested/images/penguin.png');
|
||||||
});
|
});
|
||||||
|
|
||||||
Global.run();
|
Global.run();
|
||||||
|
|
6
packages/astro/test/fixtures/astro-global/src/components/nested/InnerChild.astro
vendored
Normal file
6
packages/astro/test/fixtures/astro-global/src/components/nested/InnerChild.astro
vendored
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
const penguinUrl = Astro.resolve('./images/penguin.png');
|
||||||
|
---
|
||||||
|
<div id="inner-child">
|
||||||
|
<img src={penguinUrl} />
|
||||||
|
</div>
|
|
@ -1,5 +1,6 @@
|
||||||
---
|
---
|
||||||
import Child from '../components/ChildResolve.astro';
|
import Child from '../components/ChildResolve.astro';
|
||||||
|
import InnerChild from '../components/nested/InnerChild.astro';
|
||||||
---
|
---
|
||||||
|
|
||||||
<html>
|
<html>
|
||||||
|
@ -8,5 +9,6 @@ import Child from '../components/ChildResolve.astro';
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<Child />
|
<Child />
|
||||||
|
<InnerChild />
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
Loading…
Add table
Reference in a new issue