From cfc2fb2ba27a3840011d9e2747dcc1725a324937 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Thu, 12 Sep 2019 10:45:40 +0200 Subject: [PATCH] [REF] qweb: rename `register` method to `registerComponent` --- doc/qweb.md | 4 ++-- src/qweb/qweb.ts | 2 +- src/router/Router.ts | 2 +- tests/component/component.test.ts | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/qweb.md b/doc/qweb.md index ac08b5a0..c0e27025 100644 --- a/doc/qweb.md +++ b/doc/qweb.md @@ -138,14 +138,14 @@ It's API is quite simple: QWeb.registerTemplate('mytemplate', `
some template`); ``` -- **`register(name, Component)`**: static function to register an OWL Component +- **`registerComponent(name, Component)`**: static function to register an OWL Component to QWeb's global registry. Globally registered Components can be used in templates (see the `t-component` directive). This is useful for commonly used components accross the application. ```js class Dialog extends owl.Component { ... } - QWeb.register("Dialog", Dialog); + QWeb.registerComponent("Dialog", Dialog); ... diff --git a/src/qweb/qweb.ts b/src/qweb/qweb.ts index b61f075d..45c62e96 100644 --- a/src/qweb/qweb.ts +++ b/src/qweb/qweb.ts @@ -180,7 +180,7 @@ export class QWeb extends EventBus { } } - static register(name: string, Component: any) { + static registerComponent(name: string, Component: any) { if (QWeb.components[name]) { throw new Error(`Component '${name}' has already been registered`); } diff --git a/src/router/Router.ts b/src/router/Router.ts index 91dd3525..d039c4f1 100644 --- a/src/router/Router.ts +++ b/src/router/Router.ts @@ -75,7 +75,7 @@ export class Router { partialRoute.name = "__route__" + nextId++; } if (partialRoute.component) { - QWeb.register("__component__" + partialRoute.name, partialRoute.component); + QWeb.registerComponent("__component__" + partialRoute.name, partialRoute.component); } if (partialRoute.redirect) { this.validateDestination(partialRoute.redirect); diff --git a/tests/component/component.test.ts b/tests/component/component.test.ts index 791e5753..4f7f0a2c 100644 --- a/tests/component/component.test.ts +++ b/tests/component/component.test.ts @@ -917,7 +917,7 @@ describe("composition", () => { }); test("can use components from the global registry", async () => { - QWeb.register("WidgetB", WidgetB); + QWeb.registerComponent("WidgetB", WidgetB); env.qweb.addTemplate("ParentWidget", `
`); class ParentWidget extends Widget {} const widget = new ParentWidget(env); @@ -927,7 +927,7 @@ describe("composition", () => { }); test("don't fallback to global registry if widget defined locally", async () => { - QWeb.register("WidgetB", WidgetB); // should not use this widget + QWeb.registerComponent("WidgetB", WidgetB); // should not use this widget env.qweb.addTemplate("ParentWidget", `
`); env.qweb.addTemplate("AnotherWidgetB", `Belgium`); class AnotherWidgetB extends Widget {}