All files / src/internal/client/dev legacy.js

80% Statements 24/30
66.66% Branches 2/3
33.33% Functions 2/6
77.77% Lines 21/27

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 18 19 20 21 22 23 24 25 26 27 282x 2x 2x 2x 2x 2x 234x     234x 2x 2x 210x 210x 210x 210x         210x 210x 210x 210x 210x 210x 210x  
import * as e from '../errors.js';
import { current_component_context } from '../runtime.js';
import { get_component } from './ownership.js';
 
/** @param {Function & { filename: string }} target */
export function check_target(target) {
	if (target) {
		e.component_api_invalid_new(target.filename ?? 'a component', target.name);
	}
}
 
export function legacy_api() {
	const component = current_component_context?.function;
 
	/** @param {string} method */
	function error(method) {
		// @ts-expect-error
		const parent = get_component()?.filename ?? 'Something';
		e.component_api_changed(parent, method, component.filename);
	}
 
	return {
		$destroy: () => error('$destroy()'),
		$on: () => error('$on(...)'),
		$set: () => error('$set(...)')
	};
}