[REF] component: yet another simplification for t-widget

This commit is contained in:
Géry Debongnie
2019-05-16 22:56:10 +02:00
parent 25b633cc63
commit 5682577870
3 changed files with 41 additions and 73 deletions
+25 -55
View File
@@ -14,26 +14,20 @@ exports[`class and style attributes with t-widget dynamic t-att-style is properl
const _5 = context['state'].style;
let w4 = 4 in context.__owl__.cmap ? context.__owl__.children[context.__owl__.cmap[4]] : false;
let props4 = {};
let sameProps4 = w4 && props4 === w4.__owl__.renderProps
if (w4 && w4.__owl__.renderPromise && !w4.__owl__.isStarted && !sameProps4) {
if (w4 && w4.__owl__.renderPromise && !w4.__owl__.isStarted && props4 !== w4.__owl__.renderProps) {
w4.destroy();
w4 = false
}
let isNew4 = !w4;
if (isNew4) {
if (!w4) {
let W4 = context.widgets['child'];
if (!W4) {throw new Error(\`Cannot find the definition of widget \\"child\\"\`)}
w4 = new W4(owner, props4);
context.__owl__.cmap[4] = w4.__owl__.id;
def3 = w4._prepare();
def3 = def3.then(vnode=>{vnode.data.hook = {create(_, vn){vn.elm.style = _5}};let pvnode=h(vnode.sel, {key: 4});c1[_2_index]=pvnode;pvnode.data.hook = {insert(vn){let nvn=w4._mount(vnode, vn.elm);pvnode.elm=nvn.elm;},remove(){w4.destroy()},destroy(){w4.destroy()}}; w4.__owl__.pvnode = pvnode;});
def3 = def3.then(vnode=>{vnode.data.hook = {create(_, vn){vn.elm.style = _5}};let pvnode=h(vnode.sel, {key: 4, hook: {insert(vn){let nvn=w4._mount(vnode, vn.elm);pvnode.elm=nvn.elm;},remove(){w4.destroy()},destroy(){w4.destroy()}}});c1[_2_index]=pvnode;w4.__owl__.pvnode = pvnode;});
} else {
if (w4.__owl__.renderPromise && sameProps4) {
def3 = w4.__owl__.renderPromise;
} else {
def3 = w4._updateProps(props4, extra.forceUpdate, extra.patchQueue);
}
def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};w4.el.style=_5;let pvnode=h(w4.__owl__.pvnode.sel, {key: 4});pvnode.elm=w4.el;pvnode.data.hook = {insert(a){a.elm.parentNode.replaceChild(w4.el,a.elm);a.elm=w4.el;w4.__mount();},remove(){w4.destroy()}, destroy() {w4.destroy()}};c1[_2_index]=pvnode;});
def3 = w4._updateProps(props4, extra.forceUpdate, extra.patchQueue);
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 vn1;
@@ -54,13 +48,11 @@ exports[`class and style attributes with t-widget t-att-class is properly added/
const _5 = {a: context['state'].a,b: context['state'].b};
let w4 = 4 in context.__owl__.cmap ? context.__owl__.children[context.__owl__.cmap[4]] : false;
let props4 = {};
let sameProps4 = w4 && props4 === w4.__owl__.renderProps
if (w4 && w4.__owl__.renderPromise && !w4.__owl__.isStarted && !sameProps4) {
if (w4 && w4.__owl__.renderPromise && !w4.__owl__.isStarted && props4 !== w4.__owl__.renderProps) {
w4.destroy();
w4 = false
}
let isNew4 = !w4;
if (isNew4) {
if (!w4) {
let W4 = context.widgets['child'];
if (!W4) {throw new Error(\`Cannot find the definition of widget \\"child\\"\`)}
w4 = new W4(owner, props4);
@@ -70,14 +62,10 @@ exports[`class and style attributes with t-widget t-att-class is properly added/
if (_5[k]) {
vn.elm.classList.add(k);
}
}}};let pvnode=h(vnode.sel, {key: 4});c1[_2_index]=pvnode;pvnode.data.hook = {insert(vn){let nvn=w4._mount(vnode, vn.elm);pvnode.elm=nvn.elm;},remove(){w4.destroy()},destroy(){w4.destroy()}}; w4.__owl__.pvnode = pvnode;});
}}};let pvnode=h(vnode.sel, {key: 4, hook: {insert(vn){let nvn=w4._mount(vnode, vn.elm);pvnode.elm=nvn.elm;},remove(){w4.destroy()},destroy(){w4.destroy()}}});c1[_2_index]=pvnode;w4.__owl__.pvnode = pvnode;});
} else {
if (w4.__owl__.renderPromise && sameProps4) {
def3 = w4.__owl__.renderPromise;
} else {
def3 = w4._updateProps(props4, extra.forceUpdate, extra.patchQueue);
}
def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let cl=w4.el.classList;for (let k in _5) {if (_5[k]) {cl.add(k)} else {cl.remove(k)}}let pvnode=h(w4.__owl__.pvnode.sel, {key: 4});pvnode.elm=w4.el;pvnode.data.hook = {insert(a){a.elm.parentNode.replaceChild(w4.el,a.elm);a.elm=w4.el;w4.__mount();},remove(){w4.destroy()}, destroy() {w4.destroy()}};c1[_2_index]=pvnode;});
def3 = w4._updateProps(props4, extra.forceUpdate, extra.patchQueue);
def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let cl=w4.el.classList;for (let k in _5) {if (_5[k]) {cl.add(k)} else {cl.remove(k)}}let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;});
}
extra.promises.push(def3);
return vn1;
@@ -111,26 +99,20 @@ exports[`composition sub widgets with some state rendered in a loop 1`] = `
let def6;
let w7 = key8 in context.__owl__.cmap ? context.__owl__.children[context.__owl__.cmap[key8]] : false;
let props7 = {};
let sameProps7 = w7 && props7 === w7.__owl__.renderProps
if (w7 && w7.__owl__.renderPromise && !w7.__owl__.isStarted && !sameProps7) {
if (w7 && w7.__owl__.renderPromise && !w7.__owl__.isStarted && props7 !== w7.__owl__.renderProps) {
w7.destroy();
w7 = false
}
let isNew7 = !w7;
if (isNew7) {
if (!w7) {
let W7 = context.widgets['ChildWidget'];
if (!W7) {throw new Error(\`Cannot find the definition of widget \\"ChildWidget\\"\`)}
w7 = new W7(owner, props7);
context.__owl__.cmap[key8] = w7.__owl__.id;
def6 = w7._prepare();
def6 = def6.then(vnode=>{let pvnode=h(vnode.sel, {key: key8});c1[_5_index]=pvnode;pvnode.data.hook = {insert(vn){let nvn=w7._mount(vnode, vn.elm);pvnode.elm=nvn.elm;},remove(){w7.destroy()},destroy(){w7.destroy()}}; w7.__owl__.pvnode = pvnode;});
def6 = def6.then(vnode=>{let pvnode=h(vnode.sel, {key: key8, hook: {insert(vn){let nvn=w7._mount(vnode, vn.elm);pvnode.elm=nvn.elm;},remove(){w7.destroy()},destroy(){w7.destroy()}}});c1[_5_index]=pvnode;w7.__owl__.pvnode = pvnode;});
} else {
if (w7.__owl__.renderPromise && sameProps7) {
def6 = w7.__owl__.renderPromise;
} else {
def6 = w7._updateProps(props7, extra.forceUpdate, extra.patchQueue);
}
def6 = def6.then(()=>{if (w7.__owl__.isDestroyed) {return};let pvnode=h(w7.__owl__.pvnode.sel, {key: key8});pvnode.elm=w7.el;pvnode.data.hook = {insert(a){a.elm.parentNode.replaceChild(w7.el,a.elm);a.elm=w7.el;w7.__mount();},remove(){w7.destroy()}, destroy() {w7.destroy()}};c1[_5_index]=pvnode;});
def6 = w7._updateProps(props7, extra.forceUpdate, extra.patchQueue);
def6 = def6.then(()=>{if (w7.__owl__.isDestroyed) {return};let pvnode=w7.__owl__.pvnode;c1[_5_index]=pvnode;});
}
extra.promises.push(def6);
}
@@ -152,26 +134,20 @@ exports[`random stuff/miscellaneous snapshotting compiled code 1`] = `
let def3;
let w4 = key5 in context.__owl__.cmap ? context.__owl__.children[context.__owl__.cmap[key5]] : false;
let props4 = {flag: context['state'].flag};
let sameProps4 = w4 && props4 === w4.__owl__.renderProps
if (w4 && w4.__owl__.renderPromise && !w4.__owl__.isStarted && !sameProps4) {
if (w4 && w4.__owl__.renderPromise && !w4.__owl__.isStarted && props4 !== w4.__owl__.renderProps) {
w4.destroy();
w4 = false
}
let isNew4 = !w4;
if (isNew4) {
if (!w4) {
let W4 = context.widgets['child'];
if (!W4) {throw new Error(\`Cannot find the definition of widget \\"child\\"\`)}
w4 = new W4(owner, props4);
context.__owl__.cmap[key5] = w4.__owl__.id;
def3 = w4._prepare();
def3 = def3.then(vnode=>{let pvnode=h(vnode.sel, {key: key5});c1[_2_index]=pvnode;pvnode.data.hook = {insert(vn){let nvn=w4._mount(vnode, vn.elm);pvnode.elm=nvn.elm;},remove(){w4.destroy()},destroy(){w4.destroy()}}; w4.__owl__.pvnode = pvnode;});
def3 = def3.then(vnode=>{let pvnode=h(vnode.sel, {key: key5, hook: {insert(vn){let nvn=w4._mount(vnode, vn.elm);pvnode.elm=nvn.elm;},remove(){w4.destroy()},destroy(){w4.destroy()}}});c1[_2_index]=pvnode;w4.__owl__.pvnode = pvnode;});
} else {
if (w4.__owl__.renderPromise && sameProps4) {
def3 = w4.__owl__.renderPromise;
} else {
def3 = w4._updateProps(props4, extra.forceUpdate, extra.patchQueue);
}
def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let pvnode=h(w4.__owl__.pvnode.sel, {key: key5});pvnode.elm=w4.el;pvnode.data.hook = {insert(a){a.elm.parentNode.replaceChild(w4.el,a.elm);a.elm=w4.el;w4.__mount();},remove(){w4.destroy()}, destroy() {w4.destroy()}};c1[_2_index]=pvnode;});
def3 = w4._updateProps(props4, extra.forceUpdate, extra.patchQueue);
def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;});
}
extra.promises.push(def3);
return vn1;
@@ -191,26 +167,20 @@ exports[`random stuff/miscellaneous t-props should not be undefined (snapshottin
let def3;
let w4 = 4 in context.__owl__.cmap ? context.__owl__.children[context.__owl__.cmap[4]] : false;
let props4 = {};
let sameProps4 = w4 && props4 === w4.__owl__.renderProps
if (w4 && w4.__owl__.renderPromise && !w4.__owl__.isStarted && !sameProps4) {
if (w4 && w4.__owl__.renderPromise && !w4.__owl__.isStarted && props4 !== w4.__owl__.renderProps) {
w4.destroy();
w4 = false
}
let isNew4 = !w4;
if (isNew4) {
if (!w4) {
let W4 = context.widgets['child'];
if (!W4) {throw new Error(\`Cannot find the definition of widget \\"child\\"\`)}
w4 = new W4(owner, props4);
context.__owl__.cmap[4] = w4.__owl__.id;
def3 = w4._prepare();
def3 = def3.then(vnode=>{let pvnode=h(vnode.sel, {key: 4});c1[_2_index]=pvnode;pvnode.data.hook = {insert(vn){let nvn=w4._mount(vnode, vn.elm);pvnode.elm=nvn.elm;},remove(){w4.destroy()},destroy(){w4.destroy()}}; w4.__owl__.pvnode = pvnode;});
def3 = def3.then(vnode=>{let pvnode=h(vnode.sel, {key: 4, hook: {insert(vn){let nvn=w4._mount(vnode, vn.elm);pvnode.elm=nvn.elm;},remove(){w4.destroy()},destroy(){w4.destroy()}}});c1[_2_index]=pvnode;w4.__owl__.pvnode = pvnode;});
} else {
if (w4.__owl__.renderPromise && sameProps4) {
def3 = w4.__owl__.renderPromise;
} else {
def3 = w4._updateProps(props4, extra.forceUpdate, extra.patchQueue);
}
def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let pvnode=h(w4.__owl__.pvnode.sel, {key: 4});pvnode.elm=w4.el;pvnode.data.hook = {insert(a){a.elm.parentNode.replaceChild(w4.el,a.elm);a.elm=w4.el;w4.__mount();},remove(){w4.destroy()}, destroy() {w4.destroy()}};c1[_2_index]=pvnode;});
def3 = w4._updateProps(props4, extra.forceUpdate, extra.patchQueue);
def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;});
}
extra.promises.push(def3);
return vn1;