File size: 903 Bytes
bc20498
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import Node from './Node.js';
import compiler_warnings from '../../compiler_warnings.js';

const regex_non_whitespace_characters = /[^ \r\n\f\v\t]/;

/**
 * @template {string} Type
 * @extends Node<Type>
 */
export default class AbstractBlock extends Node {
	/** @type {import('../../render_dom/Block.js').default} */
	block;

	/** @type {import('../interfaces.js').INode[]} */
	children;

	/**
	 * @param {import('../../Component.js').default} component
	 * @param {any} parent
	 * @param {any} scope
	 * @param {any} info
	 */
	constructor(component, parent, scope, info) {
		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' && !regex_non_whitespace_characters.test(child.data))) {
			this.component.warn(this, compiler_warnings.empty_block);
		}
	}
}