diff --git a/src/core/widget.ts b/src/core/widget.ts
index 20d3cd75..2d86953e 100644
--- a/src/core/widget.ts
+++ b/src/core/widget.ts
@@ -1,8 +1,8 @@
import QWeb from "./qweb_vdom";
-import {init} from "../libs/snabbdom/src/snabbdom"
-import sdProps from "../libs/snabbdom/src/modules/props"
-import sdListeners from "../libs/snabbdom/src/modules/eventlisteners"
+import { init } from "../libs/snabbdom/src/snabbdom";
+import sdProps from "../libs/snabbdom/src/modules/props";
+import sdListeners from "../libs/snabbdom/src/modules/eventlisteners";
import { VNode } from "../libs/snabbdom/src/vnode";
const patch = init([sdProps, sdListeners]);
@@ -55,7 +55,6 @@ export default class Widget {
this.env!.qweb.addTemplate(this.name, this.template);
delete this.template;
await this.render();
-
target.appendChild(this.el!);
}
@@ -92,7 +91,6 @@ export default class Widget {
}
patch(this.vnode || this.el, vnode);
this.vnode = vnode;
-
}
// private _setElement(el: ChildNode) {
diff --git a/tests/qweb_vdom.test.ts b/tests/qweb_vdom.test.ts
index 9b49e864..402d79e3 100644
--- a/tests/qweb_vdom.test.ts
+++ b/tests/qweb_vdom.test.ts
@@ -5,7 +5,11 @@ import sdListeners from "../src/libs/snabbdom/src/modules/eventlisteners";
const patch = init([sdAttributes, sdListeners]);
-function renderToDOM(qweb: QWeb, t: string, context: EvalContext = {}): HTMLElement {
+function renderToDOM(
+ qweb: QWeb,
+ t: string,
+ context: EvalContext = {}
+): HTMLElement {
const vnode = qweb.render(t, context);
const node = document.createElement(vnode.sel!);
patch(node, vnode);
@@ -61,10 +65,8 @@ describe("error handling", () => {
test("nice warning if no template with given name", () => {
const qweb = new QWeb();
- expect(() => qweb.render('invalidname')).toThrow('does not exist');
+ expect(() => qweb.render("invalidname")).toThrow("does not exist");
});
-
-
});
describe("t-esc", () => {
@@ -338,66 +340,66 @@ describe("t-call (template calling", () => {
const qweb = new QWeb();
qweb.addTemplate("_basic-callee", "ok");
qweb.addTemplate("caller", '
');
- expect(() => qwebRender(qweb, "caller")).toThrow('Invalid tag');
+ expect(() => qwebRender(qweb, "caller")).toThrow("Invalid tag");
});
- test("with unused body", () => {
- const qweb = new QWeb();
- qweb.addTemplate("_basic-callee", "ok
");
- qweb.addTemplate("caller", 'WHEEE');
- const expected = "ok
";
- expect(qwebRender(qweb, "caller")).toBe(expected);
- });
+ test("with unused body", () => {
+ const qweb = new QWeb();
+ qweb.addTemplate("_basic-callee", "ok
");
+ qweb.addTemplate("caller", 'WHEEE');
+ const expected = "ok
";
+ expect(qwebRender(qweb, "caller")).toBe(expected);
+ });
- test("with unused setbody", () => {
- const qweb = new QWeb();
- qweb.addTemplate("_basic-callee", "ok
");
- qweb.addTemplate(
- "caller",
- ''
- );
- const expected = "ok
";
- expect(qwebRender(qweb, "caller")).toBe(expected);
- });
+ test("with unused setbody", () => {
+ const qweb = new QWeb();
+ qweb.addTemplate("_basic-callee", "ok
");
+ qweb.addTemplate(
+ "caller",
+ ''
+ );
+ const expected = "ok
";
+ expect(qwebRender(qweb, "caller")).toBe(expected);
+ });
- test("with used body", () => {
- const qweb = new QWeb();
- qweb.addTemplate("_callee-printsbody", '
');
- qweb.addTemplate("caller", 'ok');
- const expected = "ok
";
- expect(qwebRender(qweb, "caller")).toBe(expected);
- });
+ test("with used body", () => {
+ const qweb = new QWeb();
+ qweb.addTemplate("_callee-printsbody", '
');
+ qweb.addTemplate("caller", 'ok');
+ const expected = "ok
";
+ expect(qwebRender(qweb, "caller")).toBe(expected);
+ });
- test("with used set body", () => {
- const qweb = new QWeb();
- qweb.addTemplate("_callee-uses-foo", '');
- qweb.addTemplate(
- "caller",
- `
+ test("with used set body", () => {
+ const qweb = new QWeb();
+ qweb.addTemplate("_callee-uses-foo", '');
+ qweb.addTemplate(
+ "caller",
+ `
`
- );
- const expected = "ok";
- expect(qwebRender(qweb, "caller")).toBe(expected);
- });
+ );
+ const expected = "ok";
+ expect(qwebRender(qweb, "caller")).toBe(expected);
+ });
- test("inherit context", () => {
- const qweb = new QWeb();
- qweb.addTemplate("_callee-uses-foo", '');
- qweb.addTemplate(
- "caller",
- `
+ test("inherit context", () => {
+ const qweb = new QWeb();
+ qweb.addTemplate("_callee-uses-foo", '');
+ qweb.addTemplate(
+ "caller",
+ `
`
- );
- const expected = "1
";
- expect(qwebRender(qweb, "caller")).toBe(expected);
- });
+ );
+ const expected = "1
";
+ expect(qwebRender(qweb, "caller")).toBe(expected);
+ });
- test("scoped parameters", () => {
- const qweb = new QWeb();
- qweb.addTemplate("_basic-callee", `ok`);
- qweb.addTemplate(
- "caller",
- `
+ test("scoped parameters", () => {
+ const qweb = new QWeb();
+ qweb.addTemplate("_basic-callee", `ok`);
+ qweb.addTemplate(
+ "caller",
+ `
@@ -405,10 +407,10 @@ describe("t-call (template calling", () => {
`
- );
- const expected = "ok
";
- expect(qwebRender(qweb, "caller").replace(/\s/g, '')).toBe(expected);
- });
+ );
+ const expected = "ok
";
+ expect(qwebRender(qweb, "caller").replace(/\s/g, "")).toBe(expected);
+ });
});
describe("foreach", () => {
@@ -420,7 +422,7 @@ describe("foreach", () => {
`;
const expected = `[0:33][1:22][2:11]
`;
- expect(renderToString(template).replace(/\s/g, '')).toBe(expected);
+ expect(renderToString(template).replace(/\s/g, "")).toBe(expected);
});
test("iterate on items (on a element node)", () => {
@@ -429,7 +431,7 @@ describe("foreach", () => {
`;
const expected = `12
`;
- expect(renderToString(template).replace(/\s/g, '')).toBe(expected);
+ expect(renderToString(template).replace(/\s/g, "")).toBe(expected);
});
test("iterate, position", () => {
@@ -440,7 +442,7 @@ describe("foreach", () => {
`;
const expected = `-first(even)-(odd)-(even)-(odd)-last(even)
`;
- expect(renderToString(template).replace(/\s/g, '')).toBe(expected);
+ expect(renderToString(template).replace(/\s/g, "")).toBe(expected);
});
test("iterate, integer param", () => {
@@ -448,7 +450,7 @@ describe("foreach", () => {
[: ]
`;
const expected = `[0:00][1:11][2:22]
`;
- expect(renderToString(template).replace(/\s/g, '')).toBe(expected);
+ expect(renderToString(template).replace(/\s/g, "")).toBe(expected);
});
test("iterate, dict param", () => {
@@ -460,7 +462,10 @@ describe("foreach", () => {
`;
const expected = `[0:a1-even][1:b2-odd][2:c3-even]
`;
expect(
- renderToString(template, { value: { a: 1, b: 2, c: 3 } }).replace(/\s/g, '')
+ renderToString(template, { value: { a: 1, b: 2, c: 3 } }).replace(
+ /\s/g,
+ ""
+ )
).toBe(expected);
});
});
@@ -533,10 +538,12 @@ describe("misc", () => {
describe("t-on", () => {
test("can bind event handler", () => {
const qweb = new QWeb();
- qweb.addTemplate('test', ``);
+ qweb.addTemplate("test", ``);
let a = 1;
- const node = renderToDOM(qweb, 'test', {
- add() { a = 3}
+ const node = renderToDOM(qweb, "test", {
+ add() {
+ a = 3;
+ }
});
node.click();
expect(a).toBe(3);
@@ -544,13 +551,14 @@ describe("t-on", () => {
test("can bind handlers with arguments", () => {
const qweb = new QWeb();
- qweb.addTemplate('test', ``);
+ qweb.addTemplate("test", ``);
let a = 1;
- const node = renderToDOM(qweb, 'test', {
- add(n) { a = a + n}
+ const node = renderToDOM(qweb, "test", {
+ add(n) {
+ a = a + n;
+ }
});
node.click();
expect(a).toBe(6);
});
});
-