Skip to content

Commit b0d50ca

Browse files
committed
remove portal
1 parent 88bceb7 commit b0d50ca

File tree

8 files changed

+1
-2172
lines changed

8 files changed

+1
-2172
lines changed

src/compiler/code_generator.ts

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import {
1717
ASTTif,
1818
ASTTKey,
1919
ASTTOut,
20-
ASTTPortal,
2120
ASTTranslation,
2221
ASTTranslationContext,
2322
ASTTSet,
@@ -461,8 +460,6 @@ export class CodeGenerator {
461460
return this.compileTTranslation(ast, ctx);
462461
case ASTType.TTranslationContext:
463462
return this.compileTTranslationContext(ast, ctx);
464-
case ASTType.TPortal:
465-
return this.compileTPortal(ast, ctx);
466463
}
467464
}
468465

@@ -1332,26 +1329,4 @@ export class CodeGenerator {
13321329
}
13331330
return null;
13341331
}
1335-
compileTPortal(ast: ASTTPortal, ctx: Context): string {
1336-
this.helpers.add("Portal");
1337-
1338-
let { block } = ctx;
1339-
const name = this.compileInNewTarget("slot", ast.content, ctx);
1340-
let id = generateId("comp");
1341-
this.helpers.add("createComponent");
1342-
this.staticDefs.push({
1343-
id,
1344-
expr: `createComponent(app, null, false, true, false, false)`,
1345-
});
1346-
1347-
const target = compileExpr(ast.target);
1348-
const key = this.generateComponentKey();
1349-
const blockString = `${id}({target: ${target},slots: {'default': {__render: ${name}.bind(this), __ctx: ctx}}}, ${key}, node, ctx, Portal)`;
1350-
if (block) {
1351-
this.insertAnchor(block);
1352-
}
1353-
block = this.createBlock(block, "multi", ctx);
1354-
this.insertBlock(blockString, block, { ...ctx, forceNewBlock: false });
1355-
return block.varName;
1356-
}
13571332
}

src/compiler/parser.ts

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ export const enum ASTType {
2727
TCallBlock,
2828
TTranslation,
2929
TTranslationContext,
30-
TPortal,
3130
}
3231

3332
export interface BaseAST {
@@ -182,12 +181,6 @@ export interface ASTTranslationContext extends BaseAST {
182181
translationCtx: string;
183182
}
184183

185-
export interface ASTTPortal extends BaseAST {
186-
type: ASTType.TPortal;
187-
target: string;
188-
content: AST;
189-
}
190-
191184
export type AST =
192185
| ASTText
193186
| ASTComment
@@ -205,8 +198,7 @@ export type AST =
205198
| ASTLog
206199
| ASTDebug
207200
| ASTTranslation
208-
| ASTTranslationContext
209-
| ASTTPortal;
201+
| ASTTranslationContext;
210202

211203
// -----------------------------------------------------------------------------
212204
// Parser
@@ -252,7 +244,6 @@ function parseNode(node: Node, ctx: ParsingContext): AST | null {
252244
parseTDebugLog(node, ctx) ||
253245
parseTForEach(node, ctx) ||
254246
parseTIf(node, ctx) ||
255-
parseTPortal(node, ctx) ||
256247
parseTTranslation(node, ctx) ||
257248
parseTTranslationContext(node, ctx) ||
258249
parseTCall(node, ctx) ||
@@ -934,30 +925,6 @@ function parseTTranslationContext(node: Element, ctx: ParsingContext): AST | nul
934925
return wrapInTTranslationContextAST(result, translationCtx);
935926
}
936927

937-
// -----------------------------------------------------------------------------
938-
// Portal
939-
// -----------------------------------------------------------------------------
940-
941-
function parseTPortal(node: Element, ctx: ParsingContext): AST | null {
942-
if (!node.hasAttribute("t-portal")) {
943-
return null;
944-
}
945-
const target = node.getAttribute("t-portal")!;
946-
node.removeAttribute("t-portal");
947-
const content = parseNode(node, ctx);
948-
if (!content) {
949-
return {
950-
type: ASTType.Text,
951-
value: "",
952-
};
953-
}
954-
return {
955-
type: ASTType.TPortal,
956-
target,
957-
content,
958-
};
959-
}
960-
961928
// -----------------------------------------------------------------------------
962929
// helpers
963930
// -----------------------------------------------------------------------------

src/runtime/portal.ts

Lines changed: 0 additions & 90 deletions
This file was deleted.

src/runtime/rendering/template_helpers.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { BDom, createCatcher, multi, text, toggler } from "../blockdom";
44
import { html } from "../blockdom/index";
55
import { Component } from "../component";
66
import { ComponentNode } from "../component_node";
7-
import { Portal } from "../portal";
87
import { markRaw } from "../reactivity/proxy";
98
import { Markup } from "../utils";
109
import { Fiber } from "./fibers";
@@ -281,6 +280,5 @@ export const helpers = {
281280
createRef,
282281
modelExpr,
283282
createComponent,
284-
Portal,
285283
callTemplate,
286284
};

src/runtime/template_set.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { parseXML } from "../common/utils";
33
import { compile, CustomDirectives, Template, TemplateFunction } from "../compiler";
44
import { comment, createBlock, html, list, multi, text, toggler } from "./blockdom";
55
import { getContext } from "./context";
6-
import { portalTemplate } from "./portal";
76
import { helpers } from "./rendering/template_helpers";
87

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

131130
xml.nextId = 1;
132-
133-
TemplateSet.registerTemplate("__portal__", portalTemplate);

tests/compiler/parser.test.ts

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2107,29 +2107,4 @@ describe("qweb parser", () => {
21072107
ns: null,
21082108
});
21092109
});
2110-
2111-
// ---------------------------------------------------------------------------
2112-
// t-portal
2113-
// ---------------------------------------------------------------------------
2114-
test("t-portal", async () => {
2115-
expect(parse(`<t t-portal="target">Content</t>`)).toEqual({
2116-
type: ASTType.TPortal,
2117-
target: "target",
2118-
content: { type: ASTType.Text, value: "Content" },
2119-
});
2120-
});
2121-
2122-
test("t-portal with t-if", async () => {
2123-
expect(parse(`<t t-portal="target" t-if="condition">Content</t>`)).toEqual({
2124-
condition: "condition",
2125-
content: {
2126-
content: { type: ASTType.Text, value: "Content" },
2127-
target: "target",
2128-
type: ASTType.TPortal,
2129-
},
2130-
tElif: null,
2131-
tElse: null,
2132-
type: ASTType.TIf,
2133-
});
2134-
});
21352110
});

0 commit comments

Comments
 (0)