[FIX] compiler: svg in new block takes the right namespace

This commit is contained in:
Lucas Perais (lpe)
2022-01-21 09:24:40 +01:00
committed by Aaron Bohy
parent a8d88d4009
commit d88eb34d4f
3 changed files with 53 additions and 6 deletions
+6 -2
View File
@@ -127,6 +127,7 @@ interface Context {
isLast?: boolean;
translate: boolean;
tKeyExpr: string | null;
nameSpace?: string;
}
function createContext(parentCtx: Context, params?: Partial<Context>) {
@@ -137,6 +138,7 @@ function createContext(parentCtx: Context, params?: Partial<Context>) {
forceNewBlock: true,
translate: parentCtx.translate,
tKeyExpr: null,
nameSpace: parentCtx.nameSpace,
},
params
);
@@ -536,9 +538,10 @@ export class CodeGenerator {
}
// attributes
const attrs: { [key: string]: string } = {};
if (ast.ns) {
const nameSpace = ast.ns || ctx.nameSpace;
if (nameSpace && isNewBlock) {
// specific namespace uri
attrs["block-ns"] = ast.ns;
attrs["block-ns"] = nameSpace;
}
for (let key in ast.attrs) {
if (key.startsWith("t-attf")) {
@@ -654,6 +657,7 @@ export class CodeGenerator {
forceNewBlock: false,
isLast: ctx.isLast && i === children.length - 1,
tKeyExpr: ctx.tKeyExpr,
nameSpace,
});
this.compileAST(child, subCtx);
}