All files / src/compiler/phases/2-analyze/visitors Text.js

90% Statements 18/20
80% Branches 4/5
100% Functions 1/1
88.23% Lines 15/17

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 182x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 26106x 4002x     4002x 26106x  
/** @import { Text } from '#compiler' */
/** @import { Context } from '../types' */
import { is_tag_valid_with_parent } from '../../../../html-tree-validation.js';
import { regex_not_whitespace } from '../../patterns.js';
import * as e from '../../../errors.js';
 
/**
 * @param {Text} node
 * @param {Context} context
 */
export function Text(node, context) {
	if (node.parent && context.state.parent_element && regex_not_whitespace.test(node.data)) {
		if (!is_tag_valid_with_parent('#text', context.state.parent_element)) {
			e.node_invalid_placement(node, 'Text node', context.state.parent_element);
		}
	}
}