mirror of
https://github.com/sveltejs/svelte.git
synced 2024-12-01 17:30:59 +01:00
get yield blocks working
This commit is contained in:
parent
c0442b5eb1
commit
cdb8b9d01d
@ -1,5 +1,6 @@
|
||||
import deindent from '../../../utils/deindent.js';
|
||||
import CodeBuilder from '../../../utils/CodeBuilder.js';
|
||||
import getBuilders from '../utils/getBuilders.js';
|
||||
import visit from '../visit.js';
|
||||
import addComponentAttributes from './attributes/addComponentAttributes.js';
|
||||
|
||||
@ -75,14 +76,14 @@ export default function visitComponent ( generator, fragment, node ) {
|
||||
|
||||
// Component has children, put them in a separate {{yield}} block
|
||||
if ( hasChildren ) {
|
||||
const yieldName = generator.getUniqueName( `render_${name}_yield_fragment` );
|
||||
const params = fragment.params.join( ', ' );
|
||||
|
||||
const childFragment = this.current.child({
|
||||
const childFragment = fragment.child({
|
||||
type: 'component',
|
||||
name: generator.getUniqueName( `render_${name}_yield_fragment` ), // TODO should getUniqueName happen inside Fragment? probably
|
||||
target: 'target',
|
||||
localElementDepth: 0
|
||||
localElementDepth: 0,
|
||||
builders: getBuilders()
|
||||
});
|
||||
|
||||
node.children.forEach( child => {
|
||||
@ -92,7 +93,7 @@ export default function visitComponent ( generator, fragment, node ) {
|
||||
const yieldFragment = fragment.getUniqueName( `${name}_yield_fragment` );
|
||||
|
||||
fragment.builders.create.addLine(
|
||||
`var ${yieldFragment} = ${yieldName}( ${params}, ${fragment.component} );`
|
||||
`var ${yieldFragment} = ${childFragment.name}( ${params}, ${fragment.component} );`
|
||||
);
|
||||
|
||||
fragment.builders.update.addLine(
|
||||
@ -100,6 +101,8 @@ export default function visitComponent ( generator, fragment, node ) {
|
||||
);
|
||||
|
||||
componentInitProperties.push( `_yield: ${yieldFragment}`);
|
||||
|
||||
generator.addRenderer( childFragment );
|
||||
}
|
||||
|
||||
const statements = [];
|
||||
|
Loading…
Reference in New Issue
Block a user