All files / src/dom combinator.ts

100% Statements 12/12
77.78% Branches 7/9
100% Functions 2/2
100% Lines 12/12
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 241x 1x 1x 1x 1x     1x 25x       18x   2x   2x   2x   1x      
export enum Combinator {
	DESCENDANT,
	CHILD,
	ADJACENT_SIBLING,
	GENERAL_SIBLING,
}
 
export function parseCombinator(combinator: string): Combinator {
	switch (combinator){
	case undefined:
	case null:
	case '':
		return Combinator.DESCENDANT;
	case '>':
		return Combinator.CHILD;
	case '+':
		return Combinator.ADJACENT_SIBLING;
	case '~':
		return Combinator.GENERAL_SIBLING;
	default:
		throw new Error(`Unknown combinator "${combinator}"`);
	}
}