mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] *: remove useless values to t-else and t-debug
The actual value does not matter, only the fact that it is present. closes #564
This commit is contained in:
@@ -946,7 +946,7 @@ For example, here is how we could implement an `ErrorBoundary` component:
|
|||||||
<t t-if="state.error">
|
<t t-if="state.error">
|
||||||
Error handled
|
Error handled
|
||||||
</t>
|
</t>
|
||||||
<t t-else="1">
|
<t t-else="">
|
||||||
<t t-slot="default" />
|
<t t-slot="default" />
|
||||||
</t>
|
</t>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ class SomeComponent extends Component {
|
|||||||
<t t-if=device.isMobile>
|
<t t-if=device.isMobile>
|
||||||
some simplified user interface
|
some simplified user interface
|
||||||
</t>
|
</t>
|
||||||
<t t-else="1">
|
<t t-else="">
|
||||||
a more advanced user interface
|
a more advanced user interface
|
||||||
</t>
|
</t>
|
||||||
</div>`;
|
</div>`;
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ generate a virtual dom representation of the HTML.
|
|||||||
```xml
|
```xml
|
||||||
<div>
|
<div>
|
||||||
<span t-if="somecondition">Some string</span>
|
<span t-if="somecondition">Some string</span>
|
||||||
<ul t-else="1">
|
<ul t-else="">
|
||||||
<li t-foreach="messages" t-as="message">
|
<li t-foreach="messages" t-as="message">
|
||||||
<t t-esc="message"/>
|
<t t-esc="message"/>
|
||||||
</li>
|
</li>
|
||||||
@@ -101,7 +101,7 @@ precisely, the result of a template rendering should have a single root node:
|
|||||||
<!–– ok: result has one single root node ––>
|
<!–– ok: result has one single root node ––>
|
||||||
<t>
|
<t>
|
||||||
<div t-if="someCondition">foo</div>
|
<div t-if="someCondition">foo</div>
|
||||||
<span t-else="1">bar</span>
|
<span t-else="">bar</span>
|
||||||
</t>
|
</t>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -618,7 +618,7 @@ describe("lifecycle hooks", () => {
|
|||||||
<t t-if="state.ok">
|
<t t-if="state.ok">
|
||||||
<t t-component="child"/>
|
<t t-component="child"/>
|
||||||
</t>
|
</t>
|
||||||
<t t-else="1">
|
<t t-else="">
|
||||||
<div/>
|
<div/>
|
||||||
</t>
|
</t>
|
||||||
</div>`
|
</div>`
|
||||||
@@ -1399,7 +1399,7 @@ describe("composition", () => {
|
|||||||
static template = xml`
|
static template = xml`
|
||||||
<div>
|
<div>
|
||||||
<h1 t-if="state.flag">hey</h1>
|
<h1 t-if="state.flag">hey</h1>
|
||||||
<h2 t-else="1">noo</h2>
|
<h2 t-else="">noo</h2>
|
||||||
<span><ChildWidget/></span>
|
<span><ChildWidget/></span>
|
||||||
<t t-if="state.flag"><span>test</span></t>
|
<t t-if="state.flag"><span>test</span></t>
|
||||||
</div>`;
|
</div>`;
|
||||||
@@ -2425,7 +2425,7 @@ describe("other directives with t-component", () => {
|
|||||||
`
|
`
|
||||||
<div>
|
<div>
|
||||||
<div t-if="state.flag">somediv</div>
|
<div t-if="state.flag">somediv</div>
|
||||||
<t t-else="1" t-component="child"/>
|
<t t-else="" t-component="child"/>
|
||||||
</div>`
|
</div>`
|
||||||
);
|
);
|
||||||
class Child extends Widget {}
|
class Child extends Widget {}
|
||||||
@@ -4414,7 +4414,7 @@ describe("t-slot directive", () => {
|
|||||||
env.qweb.addTemplates(`
|
env.qweb.addTemplates(`
|
||||||
<templates>
|
<templates>
|
||||||
<div t-name="Parent">
|
<div t-name="Parent">
|
||||||
<Dialog><t t-set="content" t-debug="1">abc</t></Dialog>
|
<Dialog><t t-set="content" t-debug="">abc</t></Dialog>
|
||||||
</div>
|
</div>
|
||||||
<span t-name="Dialog">
|
<span t-name="Dialog">
|
||||||
<t t-slot="content"/>
|
<t t-slot="content"/>
|
||||||
@@ -4892,7 +4892,7 @@ describe("t-model directive", () => {
|
|||||||
<input type="checkbox" t-model="state.flag"/>
|
<input type="checkbox" t-model="state.flag"/>
|
||||||
<span>
|
<span>
|
||||||
<t t-if="state.flag">yes</t>
|
<t t-if="state.flag">yes</t>
|
||||||
<t t-else="1">no</t>
|
<t t-else="">no</t>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</templates>`);
|
</templates>`);
|
||||||
@@ -5171,7 +5171,7 @@ describe("environment and plugins", () => {
|
|||||||
static template = xml`
|
static template = xml`
|
||||||
<div>
|
<div>
|
||||||
<t t-if="env.someFlag">Red</t>
|
<t t-if="env.someFlag">Red</t>
|
||||||
<t t-else="1">Blue</t>
|
<t t-else="">Blue</t>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
@@ -5234,7 +5234,7 @@ describe("component error handling (catchError)", () => {
|
|||||||
static template = xml`
|
static template = xml`
|
||||||
<div>
|
<div>
|
||||||
<t t-if="state.error">Error handled</t>
|
<t t-if="state.error">Error handled</t>
|
||||||
<t t-else="1"><t t-slot="default" /></t>
|
<t t-else=""><t t-slot="default" /></t>
|
||||||
</div>`;
|
</div>`;
|
||||||
state = useState({ error: false });
|
state = useState({ error: false });
|
||||||
|
|
||||||
@@ -5310,7 +5310,7 @@ describe("component error handling (catchError)", () => {
|
|||||||
static template = xml`
|
static template = xml`
|
||||||
<div>
|
<div>
|
||||||
<t t-if="state.error">Error handled</t>
|
<t t-if="state.error">Error handled</t>
|
||||||
<t t-else="1"><t t-slot="default" /></t>
|
<t t-else=""><t t-slot="default" /></t>
|
||||||
</div>`;
|
</div>`;
|
||||||
state = useState({ error: false });
|
state = useState({ error: false });
|
||||||
|
|
||||||
@@ -5346,7 +5346,7 @@ describe("component error handling (catchError)", () => {
|
|||||||
static template = xml`
|
static template = xml`
|
||||||
<div>
|
<div>
|
||||||
<t t-if="state.error">Error handled</t>
|
<t t-if="state.error">Error handled</t>
|
||||||
<t t-else="1"><t t-slot="default" /></t>
|
<t t-else=""><t t-slot="default" /></t>
|
||||||
</div>`;
|
</div>`;
|
||||||
state = useState({ error: false });
|
state = useState({ error: false });
|
||||||
|
|
||||||
@@ -5382,7 +5382,7 @@ describe("component error handling (catchError)", () => {
|
|||||||
<templates>
|
<templates>
|
||||||
<div t-name="ErrorBoundary">
|
<div t-name="ErrorBoundary">
|
||||||
<t t-if="state.error">Error handled</t>
|
<t t-if="state.error">Error handled</t>
|
||||||
<t t-else="1"><t t-slot="default" /></t>
|
<t t-else=""><t t-slot="default" /></t>
|
||||||
</div>
|
</div>
|
||||||
<div t-name="ErrorComponent">Some text</div>
|
<div t-name="ErrorComponent">Some text</div>
|
||||||
<div t-name="App">
|
<div t-name="App">
|
||||||
@@ -5429,7 +5429,7 @@ describe("component error handling (catchError)", () => {
|
|||||||
static template = xml`
|
static template = xml`
|
||||||
<div>
|
<div>
|
||||||
<t t-if="state.error">Error handled</t>
|
<t t-if="state.error">Error handled</t>
|
||||||
<t t-else="1"><t t-slot="default" /></t>
|
<t t-else=""><t t-slot="default" /></t>
|
||||||
</div>`;
|
</div>`;
|
||||||
state = useState({ error: false });
|
state = useState({ error: false });
|
||||||
|
|
||||||
@@ -5456,7 +5456,7 @@ describe("component error handling (catchError)", () => {
|
|||||||
<templates>
|
<templates>
|
||||||
<div t-name="ErrorBoundary">
|
<div t-name="ErrorBoundary">
|
||||||
<t t-if="state.error">Error handled</t>
|
<t t-if="state.error">Error handled</t>
|
||||||
<t t-else="1"><t t-slot="default" /></t>
|
<t t-else=""><t t-slot="default" /></t>
|
||||||
</div>
|
</div>
|
||||||
<div t-name="ErrorComponent">Some text</div>
|
<div t-name="ErrorComponent">Some text</div>
|
||||||
<div t-name="App">
|
<div t-name="App">
|
||||||
@@ -5500,7 +5500,7 @@ describe("component error handling (catchError)", () => {
|
|||||||
static template = xml`
|
static template = xml`
|
||||||
<div>
|
<div>
|
||||||
<t t-if="state.error">Error handled</t>
|
<t t-if="state.error">Error handled</t>
|
||||||
<t t-else="1"><t t-slot="default" /></t>
|
<t t-else=""><t t-slot="default" /></t>
|
||||||
</div>`;
|
</div>`;
|
||||||
state = useState({ error: false });
|
state = useState({ error: false });
|
||||||
|
|
||||||
|
|||||||
@@ -426,7 +426,7 @@ describe("t-if", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("t-esc with t-elif", () => {
|
test("t-esc with t-elif", () => {
|
||||||
qweb.addTemplate("test", `<div><t t-if="false">abc</t><t t-else="1" t-esc="'x'"/></div>`);
|
qweb.addTemplate("test", `<div><t t-if="false">abc</t><t t-else="" t-esc="'x'"/></div>`);
|
||||||
expect(renderToString(qweb, "test")).toBe("<div>x</div>");
|
expect(renderToString(qweb, "test")).toBe("<div>x</div>");
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1644,7 +1644,7 @@ describe("debugging", () => {
|
|||||||
console.log = jest.fn();
|
console.log = jest.fn();
|
||||||
qweb.addTemplate(
|
qweb.addTemplate(
|
||||||
"test",
|
"test",
|
||||||
`<div t-debug="1"><t t-if="true"><span t-debug="1">hey</span></t></div>`
|
`<div t-debug=""><t t-if="true"><span t-debug="">hey</span></t></div>`
|
||||||
);
|
);
|
||||||
qweb.render("test");
|
qweb.render("test");
|
||||||
expect(qweb.templates.test.fn.toString()).toMatchSnapshot();
|
expect(qweb.templates.test.fn.toString()).toMatchSnapshot();
|
||||||
@@ -1658,7 +1658,7 @@ describe("debugging", () => {
|
|||||||
console.log = jest.fn();
|
console.log = jest.fn();
|
||||||
qweb.addTemplates(`
|
qweb.addTemplates(`
|
||||||
<templates>
|
<templates>
|
||||||
<p t-name="sub" t-debug="1">coucou</p>
|
<p t-name="sub" t-debug="">coucou</p>
|
||||||
<div t-name="test">
|
<div t-name="test">
|
||||||
<t t-call="sub"/>
|
<t t-call="sub"/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1101,7 +1101,7 @@ const RESPONSIVE_XML = `<templates>
|
|||||||
<t t-raw="maincontent"/>
|
<t t-raw="maincontent"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<t t-else="1">
|
<t t-else="">
|
||||||
<t t-raw="maincontent"/>
|
<t t-raw="maincontent"/>
|
||||||
</t>
|
</t>
|
||||||
</div>
|
</div>
|
||||||
@@ -1438,7 +1438,7 @@ const FORM_XML = `<templates>
|
|||||||
<div>Text: <t t-esc="state.text"/></div>
|
<div>Text: <t t-esc="state.text"/></div>
|
||||||
<div>Other Text: <t t-esc="state.othertext"/></div>
|
<div>Other Text: <t t-esc="state.othertext"/></div>
|
||||||
<div>Number: <t t-esc="state.number"/></div>
|
<div>Number: <t t-esc="state.number"/></div>
|
||||||
<div>Boolean: <t t-if="state.bool">True</t><t t-else="1">False</t></div>
|
<div>Boolean: <t t-if="state.bool">True</t><t t-else="">False</t></div>
|
||||||
<div>Color: <t t-esc="state.color"/></div>
|
<div>Color: <t t-esc="state.color"/></div>
|
||||||
</div>
|
</div>
|
||||||
</templates>
|
</templates>
|
||||||
|
|||||||
Reference in New Issue
Block a user