Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions src/compiler/code_generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
ASTTif,
ASTTKey,
ASTTOut,
ASTTPortal,
ASTTranslation,
ASTTranslationContext,
ASTTSet,
Expand Down Expand Up @@ -461,8 +460,6 @@ export class CodeGenerator {
return this.compileTTranslation(ast, ctx);
case ASTType.TTranslationContext:
return this.compileTTranslationContext(ast, ctx);
case ASTType.TPortal:
return this.compileTPortal(ast, ctx);
}
}

Expand Down Expand Up @@ -1332,26 +1329,4 @@ export class CodeGenerator {
}
return null;
}
compileTPortal(ast: ASTTPortal, ctx: Context): string {
this.helpers.add("Portal");

let { block } = ctx;
const name = this.compileInNewTarget("slot", ast.content, ctx);
let id = generateId("comp");
this.helpers.add("createComponent");
this.staticDefs.push({
id,
expr: `createComponent(app, null, false, true, false, false)`,
});

const target = compileExpr(ast.target);
const key = this.generateComponentKey();
const blockString = `${id}({target: ${target},slots: {'default': {__render: ${name}.bind(this), __ctx: ctx}}}, ${key}, node, ctx, Portal)`;
if (block) {
this.insertAnchor(block);
}
block = this.createBlock(block, "multi", ctx);
this.insertBlock(blockString, block, { ...ctx, forceNewBlock: false });
return block.varName;
}
}
35 changes: 1 addition & 34 deletions src/compiler/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export const enum ASTType {
TCallBlock,
TTranslation,
TTranslationContext,
TPortal,
}

export interface BaseAST {
Expand Down Expand Up @@ -182,12 +181,6 @@ export interface ASTTranslationContext extends BaseAST {
translationCtx: string;
}

export interface ASTTPortal extends BaseAST {
type: ASTType.TPortal;
target: string;
content: AST;
}

export type AST =
| ASTText
| ASTComment
Expand All @@ -205,8 +198,7 @@ export type AST =
| ASTLog
| ASTDebug
| ASTTranslation
| ASTTranslationContext
| ASTTPortal;
| ASTTranslationContext;

// -----------------------------------------------------------------------------
// Parser
Expand Down Expand Up @@ -252,7 +244,6 @@ function parseNode(node: Node, ctx: ParsingContext): AST | null {
parseTDebugLog(node, ctx) ||
parseTForEach(node, ctx) ||
parseTIf(node, ctx) ||
parseTPortal(node, ctx) ||
parseTTranslation(node, ctx) ||
parseTTranslationContext(node, ctx) ||
parseTCall(node, ctx) ||
Expand Down Expand Up @@ -934,30 +925,6 @@ function parseTTranslationContext(node: Element, ctx: ParsingContext): AST | nul
return wrapInTTranslationContextAST(result, translationCtx);
}

// -----------------------------------------------------------------------------
// Portal
// -----------------------------------------------------------------------------

function parseTPortal(node: Element, ctx: ParsingContext): AST | null {
if (!node.hasAttribute("t-portal")) {
return null;
}
const target = node.getAttribute("t-portal")!;
node.removeAttribute("t-portal");
const content = parseNode(node, ctx);
if (!content) {
return {
type: ASTType.Text,
value: "",
};
}
return {
type: ASTType.TPortal,
target,
content,
};
}

// -----------------------------------------------------------------------------
// helpers
// -----------------------------------------------------------------------------
Expand Down
90 changes: 0 additions & 90 deletions src/runtime/portal.ts

This file was deleted.

2 changes: 0 additions & 2 deletions src/runtime/rendering/template_helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { BDom, createCatcher, multi, text, toggler } from "../blockdom";
import { html } from "../blockdom/index";
import { Component } from "../component";
import { ComponentNode } from "../component_node";
import { Portal } from "../portal";
import { markRaw } from "../reactivity/proxy";
import { Markup } from "../utils";
import { Fiber } from "./fibers";
Expand Down Expand Up @@ -281,6 +280,5 @@ export const helpers = {
createRef,
modelExpr,
createComponent,
Portal,
callTemplate,
};
3 changes: 0 additions & 3 deletions src/runtime/template_set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { parseXML } from "../common/utils";
import { compile, CustomDirectives, Template, TemplateFunction } from "../compiler";
import { comment, createBlock, html, list, multi, text, toggler } from "./blockdom";
import { getContext } from "./context";
import { portalTemplate } from "./portal";
import { helpers } from "./rendering/template_helpers";

const bdom = { text, createBlock, list, multi, html, toggler, comment };
Expand Down Expand Up @@ -129,5 +128,3 @@ export function xml(...args: Parameters<typeof String.raw>) {
}

xml.nextId = 1;

TemplateSet.registerTemplate("__portal__", portalTemplate);
25 changes: 0 additions & 25 deletions tests/compiler/parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2107,29 +2107,4 @@ describe("qweb parser", () => {
ns: null,
});
});

// ---------------------------------------------------------------------------
// t-portal
// ---------------------------------------------------------------------------
test("t-portal", async () => {
expect(parse(`<t t-portal="target">Content</t>`)).toEqual({
type: ASTType.TPortal,
target: "target",
content: { type: ASTType.Text, value: "Content" },
});
});

test("t-portal with t-if", async () => {
expect(parse(`<t t-portal="target" t-if="condition">Content</t>`)).toEqual({
condition: "condition",
content: {
content: { type: ASTType.Text, value: "Content" },
target: "target",
type: ASTType.TPortal,
},
tElif: null,
tElse: null,
type: ASTType.TIf,
});
});
});
Loading