goodbye-acorn
Nic 2 weeks ago
parent 35e1e0baed
commit 6ca0605435

@ -145,7 +145,10 @@ export function parse(template, loose = false, erase = false) {
new Finish(trimmed).root(root);
// a comment between attributes is kept whole, one in JavaScript loses its line's indentation
const spans = roots.map(({ node }) => [/** @type {number} */ (node.start), /** @type {number} */ (node.end)]);
const spans = roots.map(({ node }) => [
/** @type {number} */ (node.start),
/** @type {number} */ (node.end)
]);
for (const comment of root.comments) {
if (spans.some(([start, end]) => comment.start >= start && comment.end <= end))
dedent(comment, trimmed);
@ -323,7 +326,8 @@ class Finish {
this.expression(node, node.expression);
return;
case 'RenderTag': {
const call = node.expression.type === 'ChainExpression' ? node.expression.expression : node.expression;
const call =
node.expression.type === 'ChainExpression' ? node.expression.expression : node.expression;
if (call.type !== 'CallExpression') e.render_tag_invalid_expression(node.expression);
this.expression(node, node.expression);
node.metadata = {
@ -487,7 +491,6 @@ class Finish {
`</${name}>`
);
}
}
/**

@ -1198,12 +1198,7 @@ export function create_scopes(ast, root, allow_reactive_declarations, parent) {
let found = outermost;
for (const parsed of answer.scopes) {
const node = /** @type {any} */ (parsed.node);
if (
node &&
node.start <= position &&
position < node.end &&
ours.has(parsed)
) {
if (node && node.start <= position && position < node.end && ours.has(parsed)) {
// a fragment has no span of its own: anything inside it is closer
const current = /** @type {any} */ (found.node);
if (!current || current.start === undefined || node.start >= current.start)
@ -1537,7 +1532,8 @@ export function create_scopes(ast, root, allow_reactive_declarations, parent) {
for (const param of node.parameters) {
const params = tables_of(param);
if (params !== undefined) from_tables(child_scope, params, [...context.path, node], false);
if (params !== undefined)
from_tables(child_scope, params, [...context.path, node], false);
}
for (const child of node.body.nodes) {
context.visit(child, { scope: child_scope });

Loading…
Cancel
Save