From 9b589af75a303848960e87082714be30c91be8a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Thu, 12 Sep 2019 09:39:15 +0200 Subject: [PATCH] [REF] qweb: improve generated code in some cases --- src/qweb/qweb.ts | 3 + tests/__snapshots__/animations.test.ts.snap | 12 +- .../__snapshots__/component.test.ts.snap | 114 +++---- .../props_validation.test.ts.snap | 3 +- tests/qweb/__snapshots__/qweb.test.ts.snap | 285 ++++++------------ tests/router/__snapshots__/Link.test.ts.snap | 3 +- 6 files changed, 142 insertions(+), 278 deletions(-) diff --git a/src/qweb/qweb.ts b/src/qweb/qweb.ts index e3dd7b0c..84a73675 100644 --- a/src/qweb/qweb.ts +++ b/src/qweb/qweb.ts @@ -326,6 +326,9 @@ export class QWeb extends EventBus { _compile(name: string, elem: Element, parentContext?: Context): CompiledTemplate { const isDebug = elem.attributes.hasOwnProperty("t-debug"); const ctx = new Context(name); + if (elem.tagName !== 't') { + ctx.shouldDefineResult = false; + } if (parentContext) { ctx.templates = Object.create(parentContext.templates); ctx.variables = Object.create(parentContext.variables); diff --git a/tests/__snapshots__/animations.test.ts.snap b/tests/__snapshots__/animations.test.ts.snap index 9369df43..b4add252 100644 --- a/tests/__snapshots__/animations.test.ts.snap +++ b/tests/__snapshots__/animations.test.ts.snap @@ -7,7 +7,6 @@ exports[`animations t-transition combined with component 1`] = ` let QWeb = this.constructor; let parent = context; let owner = context; - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -42,7 +41,7 @@ exports[`animations t-transition combined with component 1`] = ` def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;}); } extra.promises.push(def3); - return result; + return vn1; }" `; @@ -53,7 +52,6 @@ exports[`animations t-transition combined with t-component and t-if 1`] = ` let QWeb = this.constructor; let parent = context; let owner = context; - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -90,7 +88,7 @@ exports[`animations t-transition combined with t-component and t-if 1`] = ` } extra.promises.push(def3); } - return result; + return vn1; }" `; @@ -98,7 +96,6 @@ exports[`animations t-transition with no delay/duration 1`] = ` "function anonymous(context,extra ) { let utils = this.constructor.utils; - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('span', p1, c1); @@ -112,7 +109,7 @@ exports[`animations t-transition with no delay/duration 1`] = ` }, }; c1.push({text: \`blue\`}); - return result; + return vn1; }" `; @@ -120,7 +117,6 @@ exports[`animations t-transition, on a simple node (insert) 1`] = ` "function anonymous(context,extra ) { let utils = this.constructor.utils; - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('span', p1, c1); @@ -134,6 +130,6 @@ exports[`animations t-transition, on a simple node (insert) 1`] = ` }, }; c1.push({text: \`blue\`}); - return result; + return vn1; }" `; diff --git a/tests/component/__snapshots__/component.test.ts.snap b/tests/component/__snapshots__/component.test.ts.snap index 487aabe7..c8f2ef3e 100644 --- a/tests/component/__snapshots__/component.test.ts.snap +++ b/tests/component/__snapshots__/component.test.ts.snap @@ -7,7 +7,6 @@ exports[`async rendering delayed component with t-asyncroot directive 1`] = ` let QWeb = this.constructor; let parent = context; let owner = context; - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -80,7 +79,7 @@ exports[`async rendering delayed component with t-asyncroot directive 1`] = ` def10 = def10.then(()=>{if (w11.__owl__.isDestroyed) {return};let pvnode=w11.__owl__.pvnode;c5[_9_index]=pvnode;}); } def10.then(w11.__applyPatchQueue.bind(w11, patchQueue11)); - return result; + return vn1; }" `; @@ -91,7 +90,6 @@ exports[`async rendering fast component with t-asyncroot directive 1`] = ` let QWeb = this.constructor; let parent = context; let owner = context; - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -164,7 +162,7 @@ exports[`async rendering fast component with t-asyncroot directive 1`] = ` def10 = def10.then(()=>{if (w11.__owl__.isDestroyed) {return};let pvnode=w11.__owl__.pvnode;c5[_9_index]=pvnode;}); } extra.promises.push(def10); - return result; + return vn1; }" `; @@ -175,7 +173,6 @@ exports[`async rendering t-component with t-asyncroot directive: mixed re-render let QWeb = this.constructor; let parent = context; let owner = context; - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -248,7 +245,7 @@ exports[`async rendering t-component with t-asyncroot directive: mixed re-render def10 = def10.then(()=>{if (w11.__owl__.isDestroyed) {return};let pvnode=w11.__owl__.pvnode;c5[_9_index]=pvnode;}); } def10.then(w11.__applyPatchQueue.bind(w11, patchQueue11)); - return result; + return vn1; }" `; @@ -259,7 +256,6 @@ exports[`class and style attributes with t-component dynamic t-att-style is prop let QWeb = this.constructor; let parent = context; let owner = context; - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -292,7 +288,7 @@ exports[`class and style attributes with t-component dynamic t-att-style is prop def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};w4.el.style=_5;let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;}); } extra.promises.push(def3); - return result; + return vn1; }" `; @@ -303,7 +299,6 @@ exports[`class and style attributes with t-component t-att-class is properly add let QWeb = this.constructor; let parent = context; let owner = context; - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -339,7 +334,7 @@ exports[`class and style attributes with t-component t-att-class is properly add } w4.__owl__.classObj=_6; extra.promises.push(def3); - return result; + return vn1; }" `; @@ -347,14 +342,13 @@ exports[`class and style attributes with t-component t-att-class is properly add "function anonymous(context,extra ) { let utils = this.constructor.utils; - let result; var h = this.h; let _2 = {'c':true}; Object.assign(_2, utils.toObj({d:context['state'].d})) let c3 = [], p3 = {key:3,class:_2}; var vn3 = h('span', p3, c3); result = vn3; - return result; + return vn3; }" `; @@ -365,7 +359,6 @@ exports[`class and style attributes with t-component t-att-class is properly add let QWeb = this.constructor; let parent = context; let owner = context; - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -401,7 +394,7 @@ exports[`class and style attributes with t-component t-att-class is properly add } w4.__owl__.classObj=_6; extra.promises.push(def3); - return result; + return vn1; }" `; @@ -409,14 +402,13 @@ exports[`class and style attributes with t-component t-att-class is properly add "function anonymous(context,extra ) { let utils = this.constructor.utils; - let result; var h = this.h; let _2 = {'c':true}; Object.assign(_2, utils.toObj(context['state'].d?'d':'')) let c3 = [], p3 = {key:3,class:_2}; var vn3 = h('span', p3, c3); result = vn3; - return result; + return vn3; }" `; @@ -427,7 +419,6 @@ exports[`class and style attributes with t-component t-att-class is properly add let QWeb = this.constructor; let parent = context; let owner = context; - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -461,7 +452,7 @@ exports[`class and style attributes with t-component t-att-class is properly add } w4.__owl__.classObj=_5; extra.promises.push(def3); - return result; + return vn1; }" `; @@ -472,7 +463,6 @@ exports[`composition sub components dom state with t-keepalive is preserved 1`] let QWeb = this.constructor; let parent = context; let owner = context; - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -506,7 +496,7 @@ exports[`composition sub components dom state with t-keepalive is preserved 1`] } extra.promises.push(def3); } - return result; + return vn1; }" `; @@ -517,7 +507,6 @@ exports[`composition sub components with some state rendered in a loop 1`] = ` let QWeb = this.constructor; let parent = context; let owner = context; - let result; context = Object.create(context); var h = this.h; let c1 = [], p1 = {key:1}; @@ -567,7 +556,7 @@ exports[`composition sub components with some state rendered in a loop 1`] = ` } extra.promises.push(def6); } - return result; + return vn1; }" `; @@ -578,7 +567,6 @@ exports[`composition t-component with dynamic value 1`] = ` let QWeb = this.constructor; let parent = context; let owner = context; - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -610,7 +598,7 @@ exports[`composition t-component with dynamic value 1`] = ` def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;}); } extra.promises.push(def3); - return result; + return vn1; }" `; @@ -621,7 +609,6 @@ exports[`composition t-component with dynamic value 2 1`] = ` let QWeb = this.constructor; let parent = context; let owner = context; - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -653,7 +640,7 @@ exports[`composition t-component with dynamic value 2 1`] = ` def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;}); } extra.promises.push(def3); - return result; + return vn1; }" `; @@ -664,7 +651,6 @@ exports[`dynamic t-props basic use 1`] = ` let QWeb = this.constructor; let parent = context; let owner = context; - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -696,7 +682,7 @@ exports[`dynamic t-props basic use 1`] = ` def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;}); } extra.promises.push(def3); - return result; + return vn1; }" `; @@ -707,7 +693,6 @@ exports[`lifecycle hooks willPatch/patched hook with t-keepalive 1`] = ` let QWeb = this.constructor; let parent = context; let owner = context; - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -741,7 +726,7 @@ exports[`lifecycle hooks willPatch/patched hook with t-keepalive 1`] = ` } extra.promises.push(def3); } - return result; + return vn1; }" `; @@ -752,7 +737,6 @@ exports[`other directives with t-component t-on with handler bound to argument 1 let QWeb = this.constructor; let parent = context; let owner = context; - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -784,7 +768,7 @@ exports[`other directives with t-component t-on with handler bound to argument 1 def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;}); } extra.promises.push(def3); - return result; + return vn1; }" `; @@ -795,7 +779,6 @@ exports[`other directives with t-component t-on with handler bound to empty obje let QWeb = this.constructor; let parent = context; let owner = context; - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -827,7 +810,7 @@ exports[`other directives with t-component t-on with handler bound to empty obje def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;}); } extra.promises.push(def3); - return result; + return vn1; }" `; @@ -838,7 +821,6 @@ exports[`other directives with t-component t-on with handler bound to empty obje let QWeb = this.constructor; let parent = context; let owner = context; - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -870,7 +852,7 @@ exports[`other directives with t-component t-on with handler bound to empty obje def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;}); } extra.promises.push(def3); - return result; + return vn1; }" `; @@ -881,7 +863,6 @@ exports[`other directives with t-component t-on with handler bound to object 1`] let QWeb = this.constructor; let parent = context; let owner = context; - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -913,7 +894,7 @@ exports[`other directives with t-component t-on with handler bound to object 1`] def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;}); } extra.promises.push(def3); - return result; + return vn1; }" `; @@ -924,7 +905,6 @@ exports[`other directives with t-component t-on with prevent and self modifiers let QWeb = this.constructor; let parent = context; let owner = context; - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -956,7 +936,7 @@ exports[`other directives with t-component t-on with prevent and self modifiers def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;}); } extra.promises.push(def3); - return result; + return vn1; }" `; @@ -967,7 +947,6 @@ exports[`other directives with t-component t-on with self and prevent modifiers let QWeb = this.constructor; let parent = context; let owner = context; - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -999,7 +978,7 @@ exports[`other directives with t-component t-on with self and prevent modifiers def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;}); } extra.promises.push(def3); - return result; + return vn1; }" `; @@ -1010,7 +989,6 @@ exports[`other directives with t-component t-on with self modifier 1`] = ` let QWeb = this.constructor; let parent = context; let owner = context; - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -1042,7 +1020,7 @@ exports[`other directives with t-component t-on with self modifier 1`] = ` def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;}); } extra.promises.push(def3); - return result; + return vn1; }" `; @@ -1053,7 +1031,6 @@ exports[`other directives with t-component t-on with stop and/or prevent modifie let QWeb = this.constructor; let parent = context; let owner = context; - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -1085,7 +1062,7 @@ exports[`other directives with t-component t-on with stop and/or prevent modifie def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;}); } extra.promises.push(def3); - return result; + return vn1; }" `; @@ -1096,7 +1073,6 @@ exports[`random stuff/miscellaneous snapshotting compiled code 1`] = ` let QWeb = this.constructor; let parent = context; let owner = context; - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -1130,7 +1106,7 @@ exports[`random stuff/miscellaneous snapshotting compiled code 1`] = ` def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;}); } extra.promises.push(def3); - return result; + return vn1; }" `; @@ -1141,7 +1117,6 @@ exports[`random stuff/miscellaneous t-on with handler bound to dynamic argument let QWeb = this.constructor; let parent = context; let owner = context; - let result; context = Object.create(context); var h = this.h; let c1 = [], p1 = {key:1}; @@ -1192,14 +1167,13 @@ exports[`random stuff/miscellaneous t-on with handler bound to dynamic argument } extra.promises.push(def6); } - return result; + return vn1; }" `; exports[`t-model directive .lazy modifier 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -1217,14 +1191,13 @@ exports[`t-model directive .lazy modifier 1`] = ` if (_4 || _4 === 0) { c3.push({text: _4}); } - return result; + return vn1; }" `; exports[`t-model directive basic use, on an input 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -1242,14 +1215,13 @@ exports[`t-model directive basic use, on an input 1`] = ` if (_4 || _4 === 0) { c3.push({text: _4}); } - return result; + return vn1; }" `; exports[`t-model directive on a select 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -1288,14 +1260,13 @@ exports[`t-model directive on a select 1`] = ` if (_10 || _10 === 0) { c9.push({text: _10}); } - return result; + return vn1; }" `; exports[`t-model directive on a sub state key 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -1313,14 +1284,13 @@ exports[`t-model directive on a sub state key 1`] = ` if (_4 || _4 === 0) { c3.push({text: _4}); } - return result; + return vn1; }" `; exports[`t-model directive on an input type=radio 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -1351,14 +1321,13 @@ exports[`t-model directive on an input type=radio 1`] = ` if (_11 || _11 === 0) { c10.push({text: _11}); } - return result; + return vn1; }" `; exports[`t-model directive on an input, type=checkbox 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -1379,7 +1348,7 @@ exports[`t-model directive on an input, type=checkbox 1`] = ` else { c4.push({text: \`no\`}); } - return result; + return vn1; }" `; @@ -1390,7 +1359,6 @@ exports[`t-slot directive can define and call slots 1`] = ` let QWeb = this.constructor; let parent = context; let owner = context; - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -1423,7 +1391,7 @@ exports[`t-slot directive can define and call slots 1`] = ` def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;}); } extra.promises.push(def3); - return result; + return vn1; }" `; @@ -1431,7 +1399,6 @@ exports[`t-slot directive can define and call slots 2`] = ` "function anonymous(context,extra ) { let owner = context; - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -1450,7 +1417,7 @@ exports[`t-slot directive can define and call slots 2`] = ` if (slot5) { slot5.call(this, context.__owl__.parent, Object.assign({}, extra, {parentNode: c4, vars: extra.vars, parent: owner})); } - return result; + return vn1; }" `; @@ -1585,7 +1552,6 @@ exports[`t-slot directive slots are rendered with proper context, part 2 1`] = ` "function anonymous(context,extra ) { let owner = context; - let result; var h = this.h; var _1 = context['props'].to; let c2 = [], p2 = {key:2,attrs:{href: _1}}; @@ -1595,7 +1561,7 @@ exports[`t-slot directive slots are rendered with proper context, part 2 1`] = ` if (slot3) { slot3.call(this, context.__owl__.parent, Object.assign({}, extra, {parentNode: c2, vars: extra.vars, parent: owner})); } - return result; + return vn2; }" `; @@ -1606,7 +1572,6 @@ exports[`t-slot directive slots are rendered with proper context, part 2 2`] = ` let QWeb = this.constructor; let parent = context; let owner = context; - let result; context = Object.create(context); const scope = Object.create(null); var h = this.h; @@ -1669,7 +1634,7 @@ exports[`t-slot directive slots are rendered with proper context, part 2 2`] = ` } extra.promises.push(def8); } - return result; + return vn1; }" `; @@ -1691,7 +1656,6 @@ exports[`t-slot directive slots are rendered with proper context, part 3 1`] = ` "function anonymous(context,extra ) { let owner = context; - let result; var h = this.h; var _1 = context['props'].to; let c2 = [], p2 = {key:2,attrs:{href: _1}}; @@ -1701,7 +1665,7 @@ exports[`t-slot directive slots are rendered with proper context, part 3 1`] = ` if (slot3) { slot3.call(this, context.__owl__.parent, Object.assign({}, extra, {parentNode: c2, vars: extra.vars, parent: owner})); } - return result; + return vn2; }" `; @@ -1712,7 +1676,6 @@ exports[`t-slot directive slots are rendered with proper context, part 3 2`] = ` let QWeb = this.constructor; let parent = context; let owner = context; - let result; context = Object.create(context); const scope = Object.create(null); var h = this.h; @@ -1776,7 +1739,7 @@ exports[`t-slot directive slots are rendered with proper context, part 3 2`] = ` } extra.promises.push(def9); } - return result; + return vn1; }" `; @@ -1800,7 +1763,6 @@ exports[`t-slot directive slots are rendered with proper context, part 4 1`] = ` let QWeb = this.constructor; let parent = context; let owner = context; - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -1834,7 +1796,7 @@ exports[`t-slot directive slots are rendered with proper context, part 4 1`] = ` def4 = def4.then(()=>{if (w5.__owl__.isDestroyed) {return};let pvnode=w5.__owl__.pvnode;c1[_3_index]=pvnode;}); } extra.promises.push(def4); - return result; + return vn1; }" `; diff --git a/tests/component/__snapshots__/props_validation.test.ts.snap b/tests/component/__snapshots__/props_validation.test.ts.snap index 131a8288..0c9382aa 100644 --- a/tests/component/__snapshots__/props_validation.test.ts.snap +++ b/tests/component/__snapshots__/props_validation.test.ts.snap @@ -11,7 +11,6 @@ exports[`props validation props are validated in dev mode (code snapshot) 1`] = let QWeb = this.constructor; let parent = context; let owner = context; - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -45,6 +44,6 @@ exports[`props validation props are validated in dev mode (code snapshot) 1`] = def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;}); } extra.promises.push(def3); - return result; + return vn1; }" `; diff --git a/tests/qweb/__snapshots__/qweb.test.ts.snap b/tests/qweb/__snapshots__/qweb.test.ts.snap index 616d4f59..1686d252 100644 --- a/tests/qweb/__snapshots__/qweb.test.ts.snap +++ b/tests/qweb/__snapshots__/qweb.test.ts.snap @@ -3,143 +3,132 @@ exports[`attributes class and t-attf-class with ternary operation 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; var _1 = 'hello ' + (context['value']?'world':''); let c2 = [], p2 = {key:2,attrs:{class: _1}}; var vn2 = h('div', p2, c2); result = vn2; - return result; + return vn2; }" `; exports[`attributes dynamic attribute falsy variable 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; var _1 = context['value']; let c2 = [], p2 = {key:2,attrs:{foo: _1}}; var vn2 = h('div', p2, c2); result = vn2; - return result; + return vn2; }" `; exports[`attributes dynamic attribute with a dash 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; var _1 = context['id']; let c2 = [], p2 = {key:2,attrs:{\\"data-action-id\\": _1}}; var vn2 = h('div', p2, c2); result = vn2; - return result; + return vn2; }" `; exports[`attributes dynamic attributes 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; var _1 = 'bar'; let c2 = [], p2 = {key:2,attrs:{foo: _1}}; var vn2 = h('div', p2, c2); result = vn2; - return result; + return vn2; }" `; exports[`attributes dynamic formatted attributes with a dash 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; var _1 = \`Some text \${context['id']}\`; let c2 = [], p2 = {key:2,attrs:{\\"aria-label\\": _1}}; var vn2 = h('div', p2, c2); result = vn2; - return result; + return vn2; }" `; exports[`attributes fixed variable 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; var _1 = context['value']; let c2 = [], p2 = {key:2,attrs:{foo: _1}}; var vn2 = h('div', p2, c2); result = vn2; - return result; + return vn2; }" `; exports[`attributes format expression 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; var _1 = (context['value']+37); let c2 = [], p2 = {key:2,attrs:{foo: _1}}; var vn2 = h('div', p2, c2); result = vn2; - return result; + return vn2; }" `; exports[`attributes format expression, other format 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; var _1 = (context['value']+37); let c2 = [], p2 = {key:2,attrs:{foo: _1}}; var vn2 = h('div', p2, c2); result = vn2; - return result; + return vn2; }" `; exports[`attributes format literal 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; var _1 = \`bar\`; let c2 = [], p2 = {key:2,attrs:{foo: _1}}; var vn2 = h('div', p2, c2); result = vn2; - return result; + return vn2; }" `; exports[`attributes format multiple 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; var _1 = \`a \${context['value1']} is \${context['value2']} of \${context['value3']} ]\`; let c2 = [], p2 = {key:2,attrs:{foo: _1}}; var vn2 = h('div', p2, c2); result = vn2; - return result; + return vn2; }" `; exports[`attributes format value 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; var _1 = \`b\${context['value']}r\`; let c2 = [], p2 = {key:2,attrs:{foo: _1}}; var vn2 = h('div', p2, c2); result = vn2; - return result; + return vn2; }" `; @@ -147,7 +136,6 @@ exports[`attributes from object variables set previously 1`] = ` "function anonymous(context,extra ) { let utils = this.constructor.utils; - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -157,7 +145,7 @@ exports[`attributes from object variables set previously 1`] = ` let c4 = [], p4 = {key:4,class:_3}; var vn4 = h('span', p4, c4); c1.push(vn4); - return result; + return vn1; }" `; @@ -165,7 +153,6 @@ exports[`attributes from variables set previously 1`] = ` "function anonymous(context,extra ) { let utils = this.constructor.utils; - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -175,14 +162,13 @@ exports[`attributes from variables set previously 1`] = ` let c4 = [], p4 = {key:4,class:_3}; var vn4 = h('span', p4, c4); c1.push(vn4); - return result; + return vn1; }" `; exports[`attributes object 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; var _1 = context['value']; let c2 = [], p2 = {key:2,attrs:{}}; @@ -195,14 +181,13 @@ exports[`attributes object 1`] = ` } var vn2 = h('div', p2, c2); result = vn2; - return result; + return vn2; }" `; exports[`attributes static attributes 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; var _1 = 'a'; var _2 = 'b'; @@ -210,34 +195,32 @@ exports[`attributes static attributes 1`] = ` let c4 = [], p4 = {key:4,attrs:{foo: _1,bar: _2,baz: _3}}; var vn4 = h('div', p4, c4); result = vn4; - return result; + return vn4; }" `; exports[`attributes static attributes on void elements 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; var _1 = '/test.jpg'; var _2 = 'Test'; let c3 = [], p3 = {key:3,attrs:{src: _1,alt: _2}}; var vn3 = h('img', p3, c3); result = vn3; - return result; + return vn3; }" `; exports[`attributes static attributes with dashes 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; var _1 = 'Close'; let c2 = [], p2 = {key:2,attrs:{\\"aria-label\\": _1}}; var vn2 = h('div', p2, c2); result = vn2; - return result; + return vn2; }" `; @@ -245,14 +228,13 @@ exports[`attributes t-att-class and class should combine together 1`] = ` "function anonymous(context,extra ) { let utils = this.constructor.utils; - let result; var h = this.h; let _2 = {'hello':true}; Object.assign(_2, utils.toObj(context['value'])) let c3 = [], p3 = {key:3,class:_2}; var vn3 = h('div', p3, c3); result = vn3; - return result; + return vn3; }" `; @@ -260,34 +242,31 @@ exports[`attributes t-att-class with object 1`] = ` "function anonymous(context,extra ) { let utils = this.constructor.utils; - let result; var h = this.h; let _2 = {'static':true}; Object.assign(_2, utils.toObj({a:context['b'],c:context['d'],e:context['f']})) let c3 = [], p3 = {key:3,class:_2}; var vn3 = h('div', p3, c3); result = vn3; - return result; + return vn3; }" `; exports[`attributes t-attf-class should combine with class 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; var _1 = 'hello ' + \`world\`; let c2 = [], p2 = {key:2,attrs:{class: _1}}; var vn2 = h('div', p2, c2); result = vn2; - return result; + return vn2; }" `; exports[`attributes tuple literal 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; var _1 = ['foo','bar']; let c2 = [], p2 = {key:2,attrs:{}}; @@ -300,14 +279,13 @@ exports[`attributes tuple literal 1`] = ` } var vn2 = h('div', p2, c2); result = vn2; - return result; + return vn2; }" `; exports[`attributes tuple variable 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; var _1 = context['value']; let c2 = [], p2 = {key:2,attrs:{}}; @@ -320,14 +298,13 @@ exports[`attributes tuple variable 1`] = ` } var vn2 = h('div', p2, c2); result = vn2; - return result; + return vn2; }" `; exports[`debugging t-debug 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; debugger; let c1 = [], p1 = {key:1}; @@ -340,28 +317,26 @@ exports[`debugging t-debug 1`] = ` c1.push(vn2); c2.push({text: \`hey\`}); } - return result; + return vn1; }" `; exports[`debugging t-log 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); result = vn1; var _2 = 42; console.log(_2+3) - return result; + return vn1; }" `; exports[`foreach does not pollute the rendering context 1`] = ` "function anonymous(context,extra ) { - let result; context = Object.create(context); var h = this.h; let c1 = [], p1 = {key:1}; @@ -386,14 +361,13 @@ exports[`foreach does not pollute the rendering context 1`] = ` c1.push({text: _5}); } } - return result; + return vn1; }" `; exports[`foreach iterate on items (on a element node) 1`] = ` "function anonymous(context,extra ) { - let result; context = Object.create(context); var h = this.h; let c1 = [], p1 = {key:1}; @@ -422,14 +396,13 @@ exports[`foreach iterate on items (on a element node) 1`] = ` c5.push({text: _6}); } } - return result; + return vn1; }" `; exports[`foreach iterate on items 1`] = ` "function anonymous(context,extra ) { - let result; context = Object.create(context); var h = this.h; let c1 = [], p1 = {key:1}; @@ -466,14 +439,13 @@ exports[`foreach iterate on items 1`] = ` } c1.push({text: \`] \`}); } - return result; + return vn1; }" `; exports[`foreach iterate, dict param 1`] = ` "function anonymous(context,extra ) { - let result; context = Object.create(context); var h = this.h; let c1 = [], p1 = {key:1}; @@ -510,14 +482,13 @@ exports[`foreach iterate, dict param 1`] = ` } c1.push({text: \`] \`}); } - return result; + return vn1; }" `; exports[`foreach iterate, position 1`] = ` "function anonymous(context,extra ) { - let result; context = Object.create(context); var h = this.h; let c1 = [], p1 = {key:1}; @@ -551,14 +522,13 @@ exports[`foreach iterate, position 1`] = ` } c1.push({text: \`) \`}); } - return result; + return vn1; }" `; exports[`foreach warn if no key in some case 1`] = ` "function anonymous(context,extra ) { - let result; context = Object.create(context); var h = this.h; let c1 = [], p1 = {key:1}; @@ -586,27 +556,25 @@ exports[`foreach warn if no key in some case 1`] = ` c5.push({text: _6}); } } - return result; + return vn1; }" `; exports[`loading templates can initialize qweb with a string 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); result = vn1; c1.push({text: \`jupiler\`}); - return result; + return vn1; }" `; exports[`loading templates can load a few templates from a xml string 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('ul', p1, c1); @@ -619,7 +587,7 @@ exports[`loading templates can load a few templates from a xml string 1`] = ` var vn3 = h('li', p3, c3); c1.push(vn3); c3.push({text: \`foo\`}); - return result; + return vn1; }" `; @@ -627,7 +595,6 @@ exports[`misc global 1`] = ` "function anonymous(context,extra ) { let utils = this.constructor.utils; - let result; context = Object.create(context); var h = this.h; let c1 = [], p1 = {key:1}; @@ -705,28 +672,26 @@ exports[`misc global 1`] = ` } else { c21.push({text: \`toto default\`}); } - return result; + return vn1; }" `; exports[`special cases for some boolean html attributes/properties input type= checkbox, with t-att-checked 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; var _1 = 'checkbox'; var _2 = context['flag']; let c3 = [], p3 = {key:3,attrs:{type: _1,checked: _2},props:{checked: _2}}; var vn3 = h('input', p3, c3); result = vn3; - return result; + return vn3; }" `; exports[`special cases for some boolean html attributes/properties various boolean html attributes 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -761,14 +726,13 @@ exports[`special cases for some boolean html attributes/properties various boole let c17 = [], p17 = {key:17,attrs:{disabled: _16},props:{disabled: _16}}; var vn17 = h('button', p17, c17); c1.push(vn17); - return result; + return vn1; }" `; exports[`static templates div with a span child node 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -777,32 +741,30 @@ exports[`static templates div with a span child node 1`] = ` var vn2 = h('span', p2, c2); c1.push(vn2); c2.push({text: \`word\`}); - return result; + return vn1; }" `; exports[`static templates div with a text node 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); result = vn1; c1.push({text: \`word\`}); - return result; + return vn1; }" `; exports[`static templates empty div 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); result = vn1; - return result; + return vn1; }" `; @@ -862,7 +824,6 @@ exports[`t-call (template calling basic caller 1`] = ` exports[`t-call (template calling call with several sub nodes on same line 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -879,14 +840,13 @@ exports[`t-call (template calling call with several sub nodes on same line 1`] = var vn7 = h('span', p7, c7); c5.push(vn7); c7.push({text: \`yay\`}); - return result; + return vn1; }" `; exports[`t-call (template calling inherit context 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -895,7 +855,7 @@ exports[`t-call (template calling inherit context 1`] = ` if (_2 || _2 === 0) { c1.push({text: _2}); } - return result; + return vn1; }" `; @@ -903,7 +863,6 @@ exports[`t-call (template calling recursive template, part 1 1`] = ` "function anonymous(context,extra ) { let owner = context; - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -915,7 +874,7 @@ exports[`t-call (template calling recursive template, part 1 1`] = ` if (false) { this.recursiveFns['__3'].call(this, context, Object.assign({}, extra, {parentNode: c1, vars: {}, scope})); } - return result; + return vn1; }" `; @@ -943,7 +902,6 @@ exports[`t-call (template calling recursive template, part 2 1`] = ` "function anonymous(context,extra ) { let owner = context; - let result; context = Object.create(context); const scope = Object.create(null); var h = this.h; @@ -984,7 +942,7 @@ exports[`t-call (template calling recursive template, part 2 1`] = ` this.recursiveFns['__10'].call(this, context, Object.assign({}, extra, {parentNode: c3, vars: {_v0: context['subtree']}, scope})); } } - return result; + return vn1; }" `; @@ -1036,7 +994,6 @@ exports[`t-call (template calling recursive template, part 3 1`] = ` "function anonymous(context,extra ) { let owner = context; - let result; context = Object.create(context); const scope = Object.create(null); var h = this.h; @@ -1077,7 +1034,7 @@ exports[`t-call (template calling recursive template, part 3 1`] = ` this.recursiveFns['__10'].call(this, context, Object.assign({}, extra, {parentNode: c3, vars: {_v0: context['subtree']}, scope})); } } - return result; + return vn1; }" `; @@ -1128,7 +1085,6 @@ exports[`t-call (template calling recursive template, part 3 2`] = ` exports[`t-call (template calling scoped parameters 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -1141,14 +1097,13 @@ exports[`t-call (template calling scoped parameters 1`] = ` if (_3 || _3 === 0) { c1.push({text: _3}); } - return result; + return vn1; }" `; exports[`t-call (template calling t-call with t-if 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -1159,7 +1114,7 @@ exports[`t-call (template calling t-call with t-if 1`] = ` c1.push(vn2); c2.push({text: \`ok\`}); } - return result; + return vn1; }" `; @@ -1208,7 +1163,6 @@ exports[`t-call (template calling with used body 1`] = ` exports[`t-call (template calling with used set body 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('span', p1, c1); @@ -1219,14 +1173,13 @@ exports[`t-call (template calling with used set body 1`] = ` c1.push({text: _2}); } } - return result; + return vn1; }" `; exports[`t-esc escaping on a node 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; let c1 = [], p1 = {key:1,on:{}}; var vn1 = h('span', p1, c1); @@ -1235,14 +1188,13 @@ exports[`t-esc escaping on a node 1`] = ` if (_2 || _2 === 0) { c1.push({text: _2}); } - return result; + return vn1; }" `; exports[`t-esc escaping on a node with a body 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; let c1 = [], p1 = {key:1,on:{}}; var vn1 = h('span', p1, c1); @@ -1253,14 +1205,13 @@ exports[`t-esc escaping on a node with a body 1`] = ` } else { c1.push({text: \`nope\`}); } - return result; + return vn1; }" `; exports[`t-esc escaping on a node with a body, as a default 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; let c1 = [], p1 = {key:1,on:{}}; var vn1 = h('span', p1, c1); @@ -1271,14 +1222,13 @@ exports[`t-esc escaping on a node with a body, as a default 1`] = ` } else { c1.push({text: \`nope\`}); } - return result; + return vn1; }" `; exports[`t-esc literal 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('span', p1, c1); @@ -1287,14 +1237,13 @@ exports[`t-esc literal 1`] = ` if (_2 || _2 === 0) { c1.push({text: _2}); } - return result; + return vn1; }" `; exports[`t-esc variable 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('span', p1, c1); @@ -1303,14 +1252,13 @@ exports[`t-esc variable 1`] = ` if (_2 || _2 === 0) { c1.push({text: _2}); } - return result; + return vn1; }" `; exports[`t-if boolean value condition elif 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -1327,14 +1275,13 @@ exports[`t-if boolean value condition elif 1`] = ` else { c1.push({text: \`beer\`}); } - return result; + return vn1; }" `; exports[`t-if boolean value condition else 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -1353,14 +1300,13 @@ exports[`t-if boolean value condition else 1`] = ` var vn3 = h('span', p3, c3); c1.push(vn3); c3.push({text: \`end\`}); - return result; + return vn1; }" `; exports[`t-if boolean value condition false else 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -1379,14 +1325,13 @@ exports[`t-if boolean value condition false else 1`] = ` var vn3 = h('span', p3, c3); c1.push(vn3); c3.push({text: \`end\`}); - return result; + return vn1; }" `; exports[`t-if boolean value condition missing 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('span', p1, c1); @@ -1394,14 +1339,13 @@ exports[`t-if boolean value condition missing 1`] = ` if (context['condition']) { c1.push({text: \`fail\`}); } - return result; + return vn1; }" `; exports[`t-if boolean value false condition 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -1409,14 +1353,13 @@ exports[`t-if boolean value false condition 1`] = ` if (context['condition']) { c1.push({text: \`ok\`}); } - return result; + return vn1; }" `; exports[`t-if boolean value true condition 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -1424,14 +1367,13 @@ exports[`t-if boolean value true condition 1`] = ` if (context['condition']) { c1.push({text: \`ok\`}); } - return result; + return vn1; }" `; exports[`t-if can use some boolean operators in expressions 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -1460,14 +1402,13 @@ exports[`t-if can use some boolean operators in expressions 1`] = ` if (context['n']<3) { c1.push({text: \`nlt\`}); } - return result; + return vn1; }" `; exports[`t-key can use t-key directive on a node 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; const nodeKey1 = context['beer'].id let c1 = [], p1 = {key:nodeKey1}; @@ -1477,14 +1418,13 @@ exports[`t-key can use t-key directive on a node 1`] = ` if (_2 || _2 === 0) { c1.push({text: _2}); } - return result; + return vn1; }" `; exports[`t-key t-key directive in a list 1`] = ` "function anonymous(context,extra ) { - let result; context = Object.create(context); var h = this.h; let c1 = [], p1 = {key:1}; @@ -1513,7 +1453,7 @@ exports[`t-key t-key directive in a list 1`] = ` c5.push({text: _6}); } } - return result; + return vn1; }" `; @@ -1523,7 +1463,6 @@ exports[`t-on can bind event handler 1`] = ` "function anonymous(context,extra ) { let owner = context; - let result; var h = this.h; let c1 = [], p1 = {key:1,on:{}}; var vn1 = h('button', p1, c1); @@ -1534,7 +1473,7 @@ exports[`t-on can bind event handler 1`] = ` extra.handlers['click' + 1] = extra.handlers['click' + 1] || context['add'].bind(owner); p1.on['click'] = extra.handlers['click' + 1]; c1.push({text: \`Click\`}); - return result; + return vn1; }" `; @@ -1542,7 +1481,6 @@ exports[`t-on can bind handlers with arguments 1`] = ` "function anonymous(context,extra ) { let owner = context; - let result; var h = this.h; let c1 = [], p1 = {key:1,on:{}}; var vn1 = h('button', p1, c1); @@ -1552,7 +1490,7 @@ exports[`t-on can bind handlers with arguments 1`] = ` } p1.on['click'] = context['add'].bind(owner, 5); c1.push({text: \`Click\`}); - return result; + return vn1; }" `; @@ -1560,7 +1498,6 @@ exports[`t-on can bind handlers with empty object (with non empty inner string) "function anonymous(context,extra ) { let owner = context; - let result; var h = this.h; let c1 = [], p1 = {key:1,on:{}}; var vn1 = h('button', p1, c1); @@ -1570,7 +1507,7 @@ exports[`t-on can bind handlers with empty object (with non empty inner string) } p1.on['click'] = context['doSomething'].bind(owner, {}); c1.push({text: \`Click\`}); - return result; + return vn1; }" `; @@ -1578,7 +1515,6 @@ exports[`t-on can bind handlers with empty object 1`] = ` "function anonymous(context,extra ) { let owner = context; - let result; var h = this.h; let c1 = [], p1 = {key:1,on:{}}; var vn1 = h('button', p1, c1); @@ -1588,7 +1524,7 @@ exports[`t-on can bind handlers with empty object 1`] = ` } p1.on['click'] = context['doSomething'].bind(owner, {}); c1.push({text: \`Click\`}); - return result; + return vn1; }" `; @@ -1596,7 +1532,6 @@ exports[`t-on can bind handlers with loop variable as argument 1`] = ` "function anonymous(context,extra ) { let owner = context; - let result; context = Object.create(context); var h = this.h; let c1 = [], p1 = {key:1}; @@ -1629,7 +1564,7 @@ exports[`t-on can bind handlers with loop variable as argument 1`] = ` p6.on['click'] = context['activate'].bind(owner, context['action']); c6.push({text: \`link\`}); } - return result; + return vn1; }" `; @@ -1637,7 +1572,6 @@ exports[`t-on can bind handlers with object arguments 1`] = ` "function anonymous(context,extra ) { let owner = context; - let result; var h = this.h; let c1 = [], p1 = {key:1,on:{}}; var vn1 = h('button', p1, c1); @@ -1647,7 +1581,7 @@ exports[`t-on can bind handlers with object arguments 1`] = ` } p1.on['click'] = context['add'].bind(owner, {val:5}); c1.push({text: \`Click\`}); - return result; + return vn1; }" `; @@ -1655,7 +1589,6 @@ exports[`t-on can bind two event handlers 1`] = ` "function anonymous(context,extra ) { let owner = context; - let result; var h = this.h; let c1 = [], p1 = {key:1,on:{}}; var vn1 = h('button', p1, c1); @@ -1671,7 +1604,7 @@ exports[`t-on can bind two event handlers 1`] = ` extra.handlers['dblclick' + 1] = extra.handlers['dblclick' + 1] || context['handleDblClick'].bind(owner); p1.on['dblclick'] = extra.handlers['dblclick' + 1]; c1.push({text: \`Click\`}); - return result; + return vn1; }" `; @@ -1679,7 +1612,6 @@ exports[`t-on handler is bound to proper owner 1`] = ` "function anonymous(context,extra ) { let owner = context; - let result; var h = this.h; let c1 = [], p1 = {key:1,on:{}}; var vn1 = h('button', p1, c1); @@ -1690,7 +1622,7 @@ exports[`t-on handler is bound to proper owner 1`] = ` extra.handlers['click' + 1] = extra.handlers['click' + 1] || context['add'].bind(owner); p1.on['click'] = extra.handlers['click' + 1]; c1.push({text: \`Click\`}); - return result; + return vn1; }" `; @@ -1698,7 +1630,6 @@ exports[`t-on t-on with prevent and self modifiers (order matters) 1`] = ` "function anonymous(context,extra ) { let owner = context; - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -1715,7 +1646,7 @@ exports[`t-on t-on with prevent and self modifiers (order matters) 1`] = ` var vn3 = h('span', p3, c3); c2.push(vn3); c3.push({text: \`Button\`}); - return result; + return vn1; }" `; @@ -1723,7 +1654,6 @@ exports[`t-on t-on with prevent and/or stop modifiers 1`] = ` "function anonymous(context,extra ) { let owner = context; - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -1755,7 +1685,7 @@ exports[`t-on t-on with prevent and/or stop modifiers 1`] = ` extra.handlers['click' + 4] = extra.handlers['click' + 4] || function (e) {e.preventDefault();e.stopPropagation();context['onClickPreventedAndStopped'].call(owner, e);}; p4.on['click'] = extra.handlers['click' + 4]; c4.push({text: \`Button 3\`}); - return result; + return vn1; }" `; @@ -1763,7 +1693,6 @@ exports[`t-on t-on with self and prevent modifiers (order matters) 1`] = ` "function anonymous(context,extra ) { let owner = context; - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -1780,7 +1709,7 @@ exports[`t-on t-on with self and prevent modifiers (order matters) 1`] = ` var vn3 = h('span', p3, c3); c2.push(vn3); c3.push({text: \`Button\`}); - return result; + return vn1; }" `; @@ -1788,7 +1717,6 @@ exports[`t-on t-on with self modifier 1`] = ` "function anonymous(context,extra ) { let owner = context; - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -1817,7 +1745,7 @@ exports[`t-on t-on with self modifier 1`] = ` var vn5 = h('span', p5, c5); c4.push(vn5); c5.push({text: \`Button\`}); - return result; + return vn1; }" `; @@ -1825,7 +1753,6 @@ exports[`t-raw literal 1`] = ` "function anonymous(context,extra ) { let utils = this.constructor.utils; - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('span', p1, c1); @@ -1839,7 +1766,7 @@ exports[`t-raw literal 1`] = ` var vn4 = h('div', p4) c1.push(vn4); } - return result; + return vn1; }" `; @@ -1847,7 +1774,6 @@ exports[`t-raw not escaping 1`] = ` "function anonymous(context,extra ) { let utils = this.constructor.utils; - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -1861,7 +1787,7 @@ exports[`t-raw not escaping 1`] = ` var vn4 = h('div', p4) c1.push(vn4); } - return result; + return vn1; }" `; @@ -1869,7 +1795,6 @@ exports[`t-raw t-raw and another sibling node 1`] = ` "function anonymous(context,extra ) { let utils = this.constructor.utils; - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('span', p1, c1); @@ -1887,7 +1812,7 @@ exports[`t-raw t-raw and another sibling node 1`] = ` var vn5 = h('div', p5) c1.push(vn5); } - return result; + return vn1; }" `; @@ -1895,7 +1820,6 @@ exports[`t-raw variable 1`] = ` "function anonymous(context,extra ) { let utils = this.constructor.utils; - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('span', p1, c1); @@ -1909,14 +1833,13 @@ exports[`t-raw variable 1`] = ` var vn4 = h('div', p4) c1.push(vn4); } - return result; + return vn1; }" `; exports[`t-ref can get a dynamic ref on a node 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -1930,14 +1853,13 @@ exports[`t-ref can get a dynamic ref on a node 1`] = ` context.refs[ref3] = n.elm; }, }; - return result; + return vn1; }" `; exports[`t-ref can get a ref on a node 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -1951,14 +1873,13 @@ exports[`t-ref can get a ref on a node 1`] = ` context.refs[ref3] = n.elm; }, }; - return result; + return vn1; }" `; exports[`t-ref refs in a loop 1`] = ` "function anonymous(context,extra ) { - let result; context = Object.create(context); var h = this.h; let c1 = [], p1 = {key:1}; @@ -1993,14 +1914,13 @@ exports[`t-ref refs in a loop 1`] = ` c5.push({text: _7}); } } - return result; + return vn1; }" `; exports[`t-set evaluate value expression 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -2009,14 +1929,13 @@ exports[`t-set evaluate value expression 1`] = ` if (_2 || _2 === 0) { c1.push({text: _2}); } - return result; + return vn1; }" `; exports[`t-set evaluate value expression, part 2 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -2025,14 +1944,13 @@ exports[`t-set evaluate value expression, part 2 1`] = ` if (_2 || _2 === 0) { c1.push({text: _2}); } - return result; + return vn1; }" `; exports[`t-set set from attribute literal 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -2041,14 +1959,13 @@ exports[`t-set set from attribute literal 1`] = ` if (_2 || _2 === 0) { c1.push({text: _2}); } - return result; + return vn1; }" `; exports[`t-set set from attribute lookup 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -2057,7 +1974,7 @@ exports[`t-set set from attribute lookup 1`] = ` if (_2 || _2 === 0) { c1.push({text: _2}); } - return result; + return vn1; }" `; @@ -2075,7 +1992,6 @@ exports[`t-set set from body literal 1`] = ` exports[`t-set set from body lookup 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -2084,26 +2000,24 @@ exports[`t-set set from body lookup 1`] = ` if (_2 || _2 === 0) { c1.push({text: _2}); } - return result; + return vn1; }" `; exports[`t-set set from empty body 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); result = vn1; - return result; + return vn1; }" `; exports[`t-set t-set and t-if 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -2112,14 +2026,13 @@ exports[`t-set t-set and t-if 1`] = ` if (_2==='ok') { c1.push({text: \`grimbergen\`}); } - return result; + return vn1; }" `; exports[`t-set t-set evaluates an expression only once 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -2131,14 +2044,13 @@ exports[`t-set t-set evaluates an expression only once 1`] = ` if (_2 || _2 === 0) { c1.push({text: _2}); } - return result; + return vn1; }" `; exports[`t-set t-set should reuse variable if possible 1`] = ` "function anonymous(context,extra ) { - let result; context = Object.create(context); var h = this.h; let c1 = [], p1 = {key:1}; @@ -2172,14 +2084,13 @@ exports[`t-set t-set should reuse variable if possible 1`] = ` } _2 = context['elem'] } - return result; + return vn1; }" `; exports[`t-set value priority 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -2188,40 +2099,37 @@ exports[`t-set value priority 1`] = ` if (_2 || _2 === 0) { c1.push({text: _2}); } - return result; + return vn1; }" `; exports[`whitespace handling consecutives whitespaces are condensed into a single space 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); result = vn1; c1.push({text: \` abc \`}); - return result; + return vn1; }" `; exports[`whitespace handling nothing is done in pre tags 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('pre', p1, c1); result = vn1; c1.push({text: \` \`}); - return result; + return vn1; }" `; exports[`whitespace handling nothing is done in pre tags 2`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('pre', p1, c1); @@ -2229,14 +2137,13 @@ exports[`whitespace handling nothing is done in pre tags 2`] = ` c1.push({text: \` some text \`}); - return result; + return vn1; }" `; exports[`whitespace handling nothing is done in pre tags 3`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('pre', p1, c1); @@ -2244,27 +2151,25 @@ exports[`whitespace handling nothing is done in pre tags 3`] = ` c1.push({text: \` \`}); - return result; + return vn1; }" `; exports[`whitespace handling white space only text nodes are condensed into a single space 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); result = vn1; c1.push({text: \` \`}); - return result; + return vn1; }" `; exports[`whitespace handling whitespace only text nodes with newlines are removed 1`] = ` "function anonymous(context,extra ) { - let result; var h = this.h; let c1 = [], p1 = {key:1}; var vn1 = h('div', p1, c1); @@ -2273,6 +2178,6 @@ exports[`whitespace handling whitespace only text nodes with newlines are remove var vn2 = h('span', p2, c2); c1.push(vn2); c2.push({text: \`abc\`}); - return result; + return vn1; }" `; diff --git a/tests/router/__snapshots__/Link.test.ts.snap b/tests/router/__snapshots__/Link.test.ts.snap index e03ebed3..2912d704 100644 --- a/tests/router/__snapshots__/Link.test.ts.snap +++ b/tests/router/__snapshots__/Link.test.ts.snap @@ -5,7 +5,6 @@ exports[`Link component can render simple cases 1`] = ` ) { let utils = this.constructor.utils; let owner = context; - let result; var h = this.h; let _1 = utils.toObj({'router-link-active':context['isActive']}); var _2 = context['href']; @@ -21,6 +20,6 @@ exports[`Link component can render simple cases 1`] = ` if (slot4) { slot4.call(this, context.__owl__.parent, Object.assign({}, extra, {parentNode: c3, vars: extra.vars, parent: owner})); } - return result; + return vn3; }" `;