mirror of https://github.com/sveltejs/svelte
Merge pull request #2608 from thollander/feat/abstract-block-class
Create a new abstraction level to handle `Block`pull/2675/head
commit
05428252bc
@ -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'
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue