|
|
|
@ -1,28 +1,26 @@
|
|
|
|
import AwaitBlock from '../AwaitBlock';
|
|
|
|
import AwaitBlock from '../AwaitBlock.js';
|
|
|
|
import Body from '../Body';
|
|
|
|
import Body from '../Body.js';
|
|
|
|
import ConstTag from '../ConstTag';
|
|
|
|
import ConstTag from '../ConstTag.js';
|
|
|
|
import Comment from '../Comment';
|
|
|
|
import Comment from '../Comment.js';
|
|
|
|
import EachBlock from '../EachBlock';
|
|
|
|
import EachBlock from '../EachBlock.js';
|
|
|
|
import Document from '../Document';
|
|
|
|
import Document from '../Document.js';
|
|
|
|
import Element from '../Element';
|
|
|
|
import Element from '../Element.js';
|
|
|
|
import Head from '../Head';
|
|
|
|
import Head from '../Head.js';
|
|
|
|
import IfBlock from '../IfBlock';
|
|
|
|
import IfBlock from '../IfBlock.js';
|
|
|
|
import InlineComponent from '../InlineComponent';
|
|
|
|
import InlineComponent from '../InlineComponent.js';
|
|
|
|
import KeyBlock from '../KeyBlock';
|
|
|
|
import KeyBlock from '../KeyBlock.js';
|
|
|
|
import MustacheTag from '../MustacheTag';
|
|
|
|
import MustacheTag from '../MustacheTag.js';
|
|
|
|
import Options from '../Options';
|
|
|
|
import Options from '../Options.js';
|
|
|
|
import RawMustacheTag from '../RawMustacheTag';
|
|
|
|
import RawMustacheTag from '../RawMustacheTag.js';
|
|
|
|
import DebugTag from '../DebugTag';
|
|
|
|
import DebugTag from '../DebugTag.js';
|
|
|
|
import Slot from '../Slot';
|
|
|
|
import Slot from '../Slot.js';
|
|
|
|
import SlotTemplate from '../SlotTemplate';
|
|
|
|
import SlotTemplate from '../SlotTemplate.js';
|
|
|
|
import Text from '../Text';
|
|
|
|
import Text from '../Text.js';
|
|
|
|
import Title from '../Title';
|
|
|
|
import Title from '../Title.js';
|
|
|
|
import Window from '../Window';
|
|
|
|
import Window from '../Window.js';
|
|
|
|
import { TemplateNode } from '../../../interfaces';
|
|
|
|
import { push_array } from '../../../utils/push_array.js';
|
|
|
|
import { push_array } from '../../../utils/push_array';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export type Children = ReturnType<typeof map_children>;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @param {any} type */
|
|
|
|
function get_constructor(type) {
|
|
|
|
function get_constructor(type) {
|
|
|
|
switch (type) {
|
|
|
|
switch (type) {
|
|
|
|
case 'AwaitBlock':
|
|
|
|
case 'AwaitBlock':
|
|
|
|
@ -70,27 +68,34 @@ function get_constructor(type) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export default function map_children(component, parent, scope, children: TemplateNode[]) {
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @param {any} component
|
|
|
|
|
|
|
|
* @param {any} parent
|
|
|
|
|
|
|
|
* @param {any} scope
|
|
|
|
|
|
|
|
* @param {import('../../../interfaces.js').TemplateNode[]} children
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
export default function map_children(component, parent, scope, children) {
|
|
|
|
let last = null;
|
|
|
|
let last = null;
|
|
|
|
let ignores = [];
|
|
|
|
let ignores = [];
|
|
|
|
|
|
|
|
return children.map(/** @param {any} child */ (child) => {
|
|
|
|
return children.map((child) => {
|
|
|
|
|
|
|
|
const constructor = get_constructor(child.type);
|
|
|
|
const constructor = get_constructor(child.type);
|
|
|
|
|
|
|
|
|
|
|
|
const use_ignores = child.type !== 'Text' && child.type !== 'Comment' && ignores.length;
|
|
|
|
const use_ignores = child.type !== 'Text' && child.type !== 'Comment' && ignores.length;
|
|
|
|
|
|
|
|
if (use_ignores)
|
|
|
|
if (use_ignores) component.push_ignores(ignores);
|
|
|
|
component.push_ignores(ignores);
|
|
|
|
const node = new constructor(component, parent, scope, child);
|
|
|
|
const node = new constructor(component, parent, scope, child);
|
|
|
|
if (use_ignores) component.pop_ignores(), (ignores = []);
|
|
|
|
if (use_ignores)
|
|
|
|
|
|
|
|
component.pop_ignores(), (ignores = []);
|
|
|
|
if (node.type === 'Comment' && node.ignores.length) {
|
|
|
|
if (node.type === 'Comment' && node.ignores.length) {
|
|
|
|
push_array(ignores, node.ignores);
|
|
|
|
push_array(ignores, node.ignores);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (last)
|
|
|
|
if (last) last.next = node;
|
|
|
|
last.next = node;
|
|
|
|
node.prev = last;
|
|
|
|
node.prev = last;
|
|
|
|
last = node;
|
|
|
|
last = node;
|
|
|
|
|
|
|
|
|
|
|
|
return node;
|
|
|
|
return node;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @typedef {Class<map_children>>} Children */
|
|
|
|
|
|
|
|
|
|
|
|
|