mirror of https://github.com/sveltejs/svelte
				
				
				
			
						commit
						16430dc6bb
					
				@ -1,15 +1,14 @@
 | 
				
			|||||||
import Node from './shared/Node';
 | 
					 | 
				
			||||||
import Block from '../render-dom/Block';
 | 
					 | 
				
			||||||
import map_children from './shared/map_children';
 | 
					import map_children from './shared/map_children';
 | 
				
			||||||
 | 
					import AbstractBlock from './shared/AbstractBlock';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default class PendingBlock extends Node {
 | 
					export default class PendingBlock extends AbstractBlock {
 | 
				
			||||||
	block: Block;
 | 
					 | 
				
			||||||
	children: Node[];
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	constructor(component, parent, scope, info) {
 | 
						constructor(component, parent, scope, info) {
 | 
				
			||||||
		super(component, parent, scope, info);
 | 
							super(component, parent, scope, info);
 | 
				
			||||||
		this.children = map_children(component, parent, scope, info.children);
 | 
							this.children = map_children(component, parent, scope, info.children);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		this.warn_if_empty_block();
 | 
							if (!info.skip) {
 | 
				
			||||||
 | 
								this.warn_if_empty_block();
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -0,0 +1,25 @@
 | 
				
			|||||||
 | 
					import Block from '../../render-dom/Block';
 | 
				
			||||||
 | 
					import Component from './../../Component';
 | 
				
			||||||
 | 
					import Node from './Node';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export default class AbstractBlock extends Node {
 | 
				
			||||||
 | 
						block: Block;
 | 
				
			||||||
 | 
						children: Node[];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						constructor(component: Component, parent, scope, info: any) {
 | 
				
			||||||
 | 
							super(component, parent, scope, info);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						warn_if_empty_block() {
 | 
				
			||||||
 | 
							if (!this.children || this.children.length > 1) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							const child = this.children[0];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (!child || (child.type === 'Text' && !/[^ \r\n\f\v\t]/.test(child.data))) {
 | 
				
			||||||
 | 
								this.component.warn(this, {
 | 
				
			||||||
 | 
									code: 'empty-block',
 | 
				
			||||||
 | 
									message: 'Empty block'
 | 
				
			||||||
 | 
								});
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -1,4 +1,6 @@
 | 
				
			|||||||
export { default as compile } from './compile/index';
 | 
					export { default as compile } from './compile/index';
 | 
				
			||||||
 | 
					export { default as parse } from './parse/index';
 | 
				
			||||||
export { default as preprocess } from './preprocess/index';
 | 
					export { default as preprocess } from './preprocess/index';
 | 
				
			||||||
 | 
					export { walk } from 'estree-walker';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const VERSION = '__VERSION__';
 | 
					export const VERSION = '__VERSION__';
 | 
				
			||||||
@ -0,0 +1,10 @@
 | 
				
			|||||||
 | 
					<script>
 | 
				
			||||||
 | 
						let caption = 'a foo in its natural habitat';
 | 
				
			||||||
 | 
					</script>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<figure>
 | 
				
			||||||
 | 
						<img src='foo.jpg' alt='a picture of a foo'>
 | 
				
			||||||
 | 
						{#if caption}
 | 
				
			||||||
 | 
							<figcaption>{caption}</figcaption>
 | 
				
			||||||
 | 
						{/if}
 | 
				
			||||||
 | 
					</figure>
 | 
				
			||||||
@ -0,0 +1 @@
 | 
				
			|||||||
 | 
					[]
 | 
				
			||||||
@ -0,0 +1,9 @@
 | 
				
			|||||||
 | 
					<script>
 | 
				
			||||||
 | 
						let promise;
 | 
				
			||||||
 | 
					</script>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					{#await promise}
 | 
				
			||||||
 | 
						<p>Loading</p>
 | 
				
			||||||
 | 
					{:then data}
 | 
				
			||||||
 | 
						<p>Data: {data}</p>
 | 
				
			||||||
 | 
					{/await}
 | 
				
			||||||
@ -0,0 +1 @@
 | 
				
			|||||||
 | 
					[]
 | 
				
			||||||
@ -0,0 +1,7 @@
 | 
				
			|||||||
 | 
					<script>
 | 
				
			||||||
 | 
						let promise;
 | 
				
			||||||
 | 
					</script>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					{#await promise then data}
 | 
				
			||||||
 | 
						<p>Data: {data}</p>
 | 
				
			||||||
 | 
					{/await}
 | 
				
			||||||
@ -0,0 +1 @@
 | 
				
			|||||||
 | 
					[]
 | 
				
			||||||
					Loading…
					
					
				
		Reference in new issue