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 | 26x 26x 1654x 29x 29x 19x 10x 29x | import { HtmlCompilerModule, HtmlCompilerContext } from '../htmlCompiler';
import { MSlotNode, DocumentNode } from '../../..';
/**
* Processes <m-slot> tags by replacing them with content extracted from <m-content> tags at the point of reference.
*/
export class SlotModule implements HtmlCompilerModule {
enterNode(htmlContext: HtmlCompilerContext): void {
// check if this is a m-slot
if (MSlotNode.isMSlotNode(htmlContext.node)) {
// get contents from context, and clone in case slot is repeated
const content: DocumentNode | undefined = htmlContext.pipelineContext.fragmentContext.slotContents.get(htmlContext.node.slot)?.clone();
if (content !== undefined) {
// fill content
htmlContext.node.replaceSelf(content.childNodes);
} else {
// remove slot tag
htmlContext.node.removeSelf(true);
}
// mark as deleted
htmlContext.setDeleted();
}
}
} |