All files / src/compiler/phases/3-transform/server/visitors Identifier.js

100% Statements 22/22
100% Branches 4/4
100% Functions 1/1
100% Lines 19/19

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 202x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 17390x 13267x 25x 25x 13242x 13242x 13242x 17390x  
/** @import { Identifier, Node } from 'estree' */
/** @import { Context } from '../types.js' */
import is_reference from 'is-reference';
import * as b from '../../../../utils/builders.js';
import { build_getter } from './shared/utils.js';
 
/**
 * @param {Identifier} node
 * @param {Context} context
 */
export function Identifier(node, context) {
	if (is_reference(node, /** @type {Node} */ (context.path.at(-1)))) {
		if (node.name === '$$props') {
			return b.id('$$sanitized_props');
		}
 
		return build_getter(node, context.state);
	}
}