From ca30dff13d598c2704e258fee7f72b87181b09c0 Mon Sep 17 00:00:00 2001 From: Simon Holthausen Date: Fri, 12 May 2023 17:27:45 +0200 Subject: [PATCH] Lint and format src/compiler/compile/nodes/shared/map_children.js --- .../compile/nodes/shared/map_children.js | 127 +++++++++--------- 1 file changed, 62 insertions(+), 65 deletions(-) diff --git a/src/compiler/compile/nodes/shared/map_children.js b/src/compiler/compile/nodes/shared/map_children.js index 6f2a0dcf25..c3d0965f99 100644 --- a/src/compiler/compile/nodes/shared/map_children.js +++ b/src/compiler/compile/nodes/shared/map_children.js @@ -22,50 +22,50 @@ import { push_array } from '../../../utils/push_array.js'; /** @param {any} type */ function get_constructor(type) { - switch (type) { - case 'AwaitBlock': - return AwaitBlock; - case 'Body': - return Body; - case 'Comment': - return Comment; - case 'ConstTag': - return ConstTag; - case 'Document': - return Document; - case 'EachBlock': - return EachBlock; - case 'Element': - return Element; - case 'Head': - return Head; - case 'IfBlock': - return IfBlock; - case 'InlineComponent': - return InlineComponent; - case 'KeyBlock': - return KeyBlock; - case 'MustacheTag': - return MustacheTag; - case 'Options': - return Options; - case 'RawMustacheTag': - return RawMustacheTag; - case 'DebugTag': - return DebugTag; - case 'Slot': - return Slot; - case 'SlotTemplate': - return SlotTemplate; - case 'Text': - return Text; - case 'Title': - return Title; - case 'Window': - return Window; - default: - throw new Error(`Not implemented: ${type}`); - } + switch (type) { + case 'AwaitBlock': + return AwaitBlock; + case 'Body': + return Body; + case 'Comment': + return Comment; + case 'ConstTag': + return ConstTag; + case 'Document': + return Document; + case 'EachBlock': + return EachBlock; + case 'Element': + return Element; + case 'Head': + return Head; + case 'IfBlock': + return IfBlock; + case 'InlineComponent': + return InlineComponent; + case 'KeyBlock': + return KeyBlock; + case 'MustacheTag': + return MustacheTag; + case 'Options': + return Options; + case 'RawMustacheTag': + return RawMustacheTag; + case 'DebugTag': + return DebugTag; + case 'Slot': + return Slot; + case 'SlotTemplate': + return SlotTemplate; + case 'Text': + return Text; + case 'Title': + return Title; + case 'Window': + return Window; + default: + throw new Error(`Not implemented: ${type}`); + } } /** @@ -75,27 +75,24 @@ function get_constructor(type) { * @param {import('../../../interfaces.js').TemplateNode[]} children */ export default function map_children(component, parent, scope, children) { - let last = null; - let ignores = []; - return children.map(/** @param {any} child */ (child) => { - const constructor = get_constructor(child.type); - const use_ignores = child.type !== 'Text' && child.type !== 'Comment' && ignores.length; - if (use_ignores) - component.push_ignores(ignores); - const node = new constructor(component, parent, scope, child); - if (use_ignores) - component.pop_ignores(), (ignores = []); - if (node.type === 'Comment' && node.ignores.length) { - push_array(ignores, node.ignores); - } - if (last) - last.next = node; - node.prev = last; - last = node; - return node; - }); + let last = null; + let ignores = []; + return children.map( + /** @param {any} child */ (child) => { + const constructor = get_constructor(child.type); + const use_ignores = child.type !== 'Text' && child.type !== 'Comment' && ignores.length; + if (use_ignores) component.push_ignores(ignores); + const node = new constructor(component, parent, scope, child); + if (use_ignores) component.pop_ignores(), (ignores = []); + if (node.type === 'Comment' && node.ignores.length) { + push_array(ignores, node.ignores); + } + if (last) last.next = node; + node.prev = last; + last = node; + return node; + } + ); } - /** @typedef {Class>} Children */ -