[REF] qweb: rename register method to registerComponent

This commit is contained in:
Géry Debongnie
2019-09-12 10:45:40 +02:00
parent d57017b6ed
commit cfc2fb2ba2
4 changed files with 6 additions and 6 deletions
+2 -2
View File
@@ -138,14 +138,14 @@ It's API is quite simple:
QWeb.registerTemplate('mytemplate', `<div>some template`); QWeb.registerTemplate('mytemplate', `<div>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 to QWeb's global registry. Globally registered Components can be used in
templates (see the `t-component` directive). This is useful for commonly used templates (see the `t-component` directive). This is useful for commonly used
components accross the application. components accross the application.
```js ```js
class Dialog extends owl.Component { ... } class Dialog extends owl.Component { ... }
QWeb.register("Dialog", Dialog); QWeb.registerComponent("Dialog", Dialog);
... ...
+1 -1
View File
@@ -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]) { if (QWeb.components[name]) {
throw new Error(`Component '${name}' has already been registered`); throw new Error(`Component '${name}' has already been registered`);
} }
+1 -1
View File
@@ -75,7 +75,7 @@ export class Router {
partialRoute.name = "__route__" + nextId++; partialRoute.name = "__route__" + nextId++;
} }
if (partialRoute.component) { if (partialRoute.component) {
QWeb.register("__component__" + partialRoute.name, partialRoute.component); QWeb.registerComponent("__component__" + partialRoute.name, partialRoute.component);
} }
if (partialRoute.redirect) { if (partialRoute.redirect) {
this.validateDestination(partialRoute.redirect); this.validateDestination(partialRoute.redirect);
+2 -2
View File
@@ -917,7 +917,7 @@ describe("composition", () => {
}); });
test("can use components from the global registry", async () => { test("can use components from the global registry", async () => {
QWeb.register("WidgetB", WidgetB); QWeb.registerComponent("WidgetB", WidgetB);
env.qweb.addTemplate("ParentWidget", `<div><t t-component="WidgetB"/></div>`); env.qweb.addTemplate("ParentWidget", `<div><t t-component="WidgetB"/></div>`);
class ParentWidget extends Widget {} class ParentWidget extends Widget {}
const widget = new ParentWidget(env); const widget = new ParentWidget(env);
@@ -927,7 +927,7 @@ describe("composition", () => {
}); });
test("don't fallback to global registry if widget defined locally", async () => { 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", `<div><t t-component="WidgetB"/></div>`); env.qweb.addTemplate("ParentWidget", `<div><t t-component="WidgetB"/></div>`);
env.qweb.addTemplate("AnotherWidgetB", `<span>Belgium</span>`); env.qweb.addTemplate("AnotherWidgetB", `<span>Belgium</span>`);
class AnotherWidgetB extends Widget {} class AnotherWidgetB extends Widget {}