[REF] component: use __ for private methods

closes #202
This commit is contained in:
Géry Debongnie
2019-06-24 13:02:12 +02:00
parent 3d2e2a1873
commit 34695883c2
8 changed files with 160 additions and 152 deletions
+7
View File
@@ -123,6 +123,8 @@ find a template with the component name (or one of its ancestor).
### Methods ### Methods
We explain here all the public methods of the `Component` class.
- **`mount(target)`** (async): this is the main way a component's hierarchy is added to the - **`mount(target)`** (async): this is the main way a component's hierarchy is added to the
DOM: the root component is mounted to a target HTMLElement. Obviously, this DOM: the root component is mounted to a target HTMLElement. Obviously, this
is asynchronous, since each children need to be created as well. Most applications is asynchronous, since each children need to be created as well. Most applications
@@ -157,6 +159,11 @@ find a template with the component name (or one of its ancestor).
called directly (except maybe on the root component), but should be done by the called directly (except maybe on the root component), but should be done by the
framework instead. framework instead.
Obviously, these methods are reserved for Owl, and should not be used by Owl
users, unless they want to override them. Also, Owl reserves all method names
starting with `__`, in order to prevent possible future conflicts with user code
whenever Owl needs to change.
### Lifecycle ### Lifecycle
A solid and robust component system needs useful hooks/methods to help A solid and robust component system needs useful hooks/methods to help
+35 -34
View File
@@ -116,10 +116,10 @@ export class Component<T extends Env, Props extends {}, State extends {}> {
constructor(parent: Component<T, any, any> | T, props?: Props) { constructor(parent: Component<T, any, any> | T, props?: Props) {
const defaultProps = (<any>this.constructor).defaultProps; const defaultProps = (<any>this.constructor).defaultProps;
if (defaultProps) { if (defaultProps) {
props = this._applyDefaultProps(props, defaultProps); props = this.__applyDefaultProps(props, defaultProps);
} }
if (QWeb.dev) { if (QWeb.dev) {
this._validateProps(props || {}); this.__validateProps(props || {});
} }
// is this a good idea? // is this a good idea?
// Pro: if props is empty, we can create easily a component // Pro: if props is empty, we can create easily a component
@@ -251,22 +251,22 @@ export class Component<T extends Env, Props extends {}, State extends {}> {
* created declaratively in templates are managed by the Owl system. * created declaratively in templates are managed by the Owl system.
*/ */
async mount(target: HTMLElement): Promise<void> { async mount(target: HTMLElement): Promise<void> {
const vnode = await this._prepare(); const vnode = await this.__prepare();
if (this.__owl__.isDestroyed) { if (this.__owl__.isDestroyed) {
// component was destroyed before we get here... // component was destroyed before we get here...
return; return;
} }
this._patch(vnode); this.__patch(vnode);
target.appendChild(this.el!); target.appendChild(this.el!);
if (document.body.contains(target)) { if (document.body.contains(target)) {
this._callMounted(); this.__callMounted();
} }
} }
unmount() { unmount() {
if (this.__owl__.isMounted) { if (this.__owl__.isMounted) {
this._callWillUnmount(); this.__callWillUnmount();
this.el!.remove(); this.el!.remove();
} }
} }
@@ -280,14 +280,14 @@ export class Component<T extends Env, Props extends {}, State extends {}> {
if (shouldPatch) { if (shouldPatch) {
patchQueue = []; patchQueue = [];
} }
const renderVDom = this._render(force, patchQueue); const renderVDom = this.__render(force, patchQueue);
const renderId = __owl__.renderId; const renderId = __owl__.renderId;
await renderVDom; await renderVDom;
if (shouldPatch && __owl__.isMounted && renderId === __owl__.renderId) { if (shouldPatch && __owl__.isMounted && renderId === __owl__.renderId) {
// we only update the vnode and the actual DOM if no other rendering // we only update the vnode and the actual DOM if no other rendering
// occurred between now and when the render method was initially called. // occurred between now and when the render method was initially called.
this._applyPatchQueue(<any[]>patchQueue); this.__applyPatchQueue(<any[]>patchQueue);
} }
} }
@@ -304,7 +304,7 @@ export class Component<T extends Env, Props extends {}, State extends {}> {
const __owl__ = this.__owl__; const __owl__ = this.__owl__;
if (!__owl__.isDestroyed) { if (!__owl__.isDestroyed) {
const el = this.el; const el = this.el;
this._destroy(__owl__.parent); this.__destroy(__owl__.parent);
if (el) { if (el) {
el.remove(); el.remove();
} }
@@ -361,7 +361,7 @@ export class Component<T extends Env, Props extends {}, State extends {}> {
// Private // Private
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
_destroy(parent: Component<any, any, any> | null) { __destroy(parent: Component<any, any, any> | null) {
const __owl__ = this.__owl__; const __owl__ = this.__owl__;
const isMounted = __owl__.isMounted; const isMounted = __owl__.isMounted;
if (isMounted) { if (isMounted) {
@@ -370,7 +370,7 @@ export class Component<T extends Env, Props extends {}, State extends {}> {
} }
const children = __owl__.children; const children = __owl__.children;
for (let key in children) { for (let key in children) {
children[key]._destroy(this); children[key].__destroy(this);
} }
if (parent) { if (parent) {
let id = __owl__.id; let id = __owl__.id;
@@ -381,13 +381,13 @@ export class Component<T extends Env, Props extends {}, State extends {}> {
delete __owl__.vnode; delete __owl__.vnode;
} }
_callMounted() { __callMounted() {
const __owl__ = this.__owl__; const __owl__ = this.__owl__;
const children = __owl__.children; const children = __owl__.children;
for (let id in children) { for (let id in children) {
const comp = children[id]; const comp = children[id];
if (!comp.__owl__.isMounted && this.el!.contains(comp.el)) { if (!comp.__owl__.isMounted && this.el!.contains(comp.el)) {
comp._callMounted(); comp.__callMounted();
} }
} }
__owl__.isMounted = true; __owl__.isMounted = true;
@@ -398,7 +398,7 @@ export class Component<T extends Env, Props extends {}, State extends {}> {
this.mounted(); this.mounted();
} }
_callWillUnmount() { __callWillUnmount() {
this.willUnmount(); this.willUnmount();
const __owl__ = this.__owl__; const __owl__ = this.__owl__;
__owl__.isMounted = false; __owl__.isMounted = false;
@@ -406,12 +406,12 @@ export class Component<T extends Env, Props extends {}, State extends {}> {
for (let id in children) { for (let id in children) {
const comp = children[id]; const comp = children[id];
if (comp.__owl__.isMounted) { if (comp.__owl__.isMounted) {
comp._callWillUnmount(); comp.__callWillUnmount();
} }
} }
} }
async _updateProps( async __updateProps(
nextProps: Props, nextProps: Props,
forceUpdate: boolean = false, forceUpdate: boolean = false,
patchQueue?: any[] patchQueue?: any[]
@@ -420,10 +420,10 @@ export class Component<T extends Env, Props extends {}, State extends {}> {
if (shouldUpdate) { if (shouldUpdate) {
const defaultProps = (<any>this.constructor).defaultProps; const defaultProps = (<any>this.constructor).defaultProps;
if (defaultProps) { if (defaultProps) {
nextProps = this._applyDefaultProps(nextProps, defaultProps); nextProps = this.__applyDefaultProps(nextProps, defaultProps);
} }
if (QWeb.dev) { if (QWeb.dev) {
this._validateProps(nextProps); this.__validateProps(nextProps);
} }
await this.willUpdateProps(nextProps); await this.willUpdateProps(nextProps);
this.props = nextProps; this.props = nextProps;
@@ -431,20 +431,21 @@ export class Component<T extends Env, Props extends {}, State extends {}> {
} }
} }
_patch(vnode) { __patch(vnode) {
const __owl__ = this.__owl__; const __owl__ = this.__owl__;
__owl__.renderPromise = null; __owl__.renderPromise = null;
const target = __owl__.vnode || document.createElement(vnode.sel!); const target = __owl__.vnode || document.createElement(vnode.sel!);
__owl__.vnode = patch(target, vnode); __owl__.vnode = patch(target, vnode);
} }
_prepare(): Promise<VNode> {
__prepare(): Promise<VNode> {
const __owl__ = this.__owl__; const __owl__ = this.__owl__;
__owl__.renderProps = this.props; __owl__.renderProps = this.props;
__owl__.renderPromise = this._prepareAndRender(); __owl__.renderPromise = this.__prepareAndRender();
return __owl__.renderPromise; return __owl__.renderPromise;
} }
async _prepareAndRender(): Promise<VNode> { async __prepareAndRender(): Promise<VNode> {
await this.willStart(); await this.willStart();
const __owl__ = this.__owl__; const __owl__ = this.__owl__;
if (__owl__.isDestroyed) { if (__owl__.isDestroyed) {
@@ -481,11 +482,11 @@ export class Component<T extends Env, Props extends {}, State extends {}> {
} }
} }
__owl__.render = qweb.render.bind(qweb, this.template); __owl__.render = qweb.render.bind(qweb, this.template);
this._observeState(); this.__observeState();
return this._render(); return this.__render();
} }
async _render( async __render(
force: boolean = false, force: boolean = false,
patchQueue: any[] = [] patchQueue: any[] = []
): Promise<VNode> { ): Promise<VNode> {
@@ -525,11 +526,11 @@ export class Component<T extends Env, Props extends {}, State extends {}> {
/** /**
* Only called by qweb t-component directive * Only called by qweb t-component directive
*/ */
_mount(vnode: VNode, elm: HTMLElement): VNode { __mount(vnode: VNode, elm: HTMLElement): VNode {
const __owl__ = this.__owl__; const __owl__ = this.__owl__;
__owl__.vnode = patch(elm, vnode); __owl__.vnode = patch(elm, vnode);
if (__owl__.parent!.__owl__.isMounted && !__owl__.isMounted) { if (__owl__.parent!.__owl__.isMounted && !__owl__.isMounted) {
this._callMounted(); this.__callMounted();
} }
return __owl__.vnode; return __owl__.vnode;
} }
@@ -537,7 +538,7 @@ export class Component<T extends Env, Props extends {}, State extends {}> {
/** /**
* Only called by qweb t-component directive (when t-keepalive is set) * Only called by qweb t-component directive (when t-keepalive is set)
*/ */
_remount() { __remount() {
const __owl__ = this.__owl__; const __owl__ = this.__owl__;
if (!__owl__.isMounted) { if (!__owl__.isMounted) {
__owl__.isMounted = true; __owl__.isMounted = true;
@@ -545,7 +546,7 @@ export class Component<T extends Env, Props extends {}, State extends {}> {
} }
} }
_observeState() { __observeState() {
if (this.state) { if (this.state) {
const __owl__ = this.__owl__; const __owl__ = this.__owl__;
__owl__.observer = new Observer(); __owl__.observer = new Observer();
@@ -560,7 +561,7 @@ export class Component<T extends Env, Props extends {}, State extends {}> {
* Note that this method does not modify in place the props, it returns a new * Note that this method does not modify in place the props, it returns a new
* prop object * prop object
*/ */
_applyDefaultProps(props: Object | undefined, defaultProps: Object): Props { __applyDefaultProps(props: Object | undefined, defaultProps: Object): Props {
props = props ? Object.create(props) : {}; props = props ? Object.create(props) : {};
for (let propName in defaultProps) { for (let propName in defaultProps) {
if (props![propName] === undefined) { if (props![propName] === undefined) {
@@ -574,10 +575,10 @@ export class Component<T extends Env, Props extends {}, State extends {}> {
* Apply the given patch queue. A patch is a pair [c, vn], where c is a * Apply the given patch queue. A patch is a pair [c, vn], where c is a
* Component instance and vn a VNode. * Component instance and vn a VNode.
* 1) Call 'willPatch' on the component of each patch * 1) Call 'willPatch' on the component of each patch
* 2) Call '_patch' on the component of each patch * 2) Call '__patch' on the component of each patch
* 3) Call 'patched' on the component of each patch, in inverse order * 3) Call 'patched' on the component of each patch, in inverse order
*/ */
_applyPatchQueue(patchQueue: any[]) { __applyPatchQueue(patchQueue: any[]) {
const patchLen = patchQueue.length; const patchLen = patchQueue.length;
for (let i = 0; i < patchLen; i++) { for (let i = 0; i < patchLen; i++) {
const patch = patchQueue[i]; const patch = patchQueue[i];
@@ -585,7 +586,7 @@ export class Component<T extends Env, Props extends {}, State extends {}> {
} }
for (let i = 0; i < patchLen; i++) { for (let i = 0; i < patchLen; i++) {
const patch = patchQueue[i]; const patch = patchQueue[i];
patch[0]._patch(patch[1]); patch[0].__patch(patch[1]);
} }
for (let i = patchLen - 1; i >= 0; i--) { for (let i = patchLen - 1; i >= 0; i--) {
const patch = patchQueue[i]; const patch = patchQueue[i];
@@ -599,7 +600,7 @@ export class Component<T extends Env, Props extends {}, State extends {}> {
* visit recursively the props and all the children to check if they are valid. * visit recursively the props and all the children to check if they are valid.
* This is why it is only done in 'dev' mode. * This is why it is only done in 'dev' mode.
*/ */
_validateProps(props: Object) { __validateProps(props: Object) {
const propsDef = (<any>this.constructor).props; const propsDef = (<any>this.constructor).props;
if (propsDef instanceof Array) { if (propsDef instanceof Array) {
// list of strings (prop names) // list of strings (prop names)
+11 -11
View File
@@ -285,9 +285,9 @@ const T_COMPONENT_MODS_CODE = Object.assign({}, MODS_CODE, {
* // perspective. * // perspective.
* context.__owl__.cmap[key5] = w4.__owl__.id; * context.__owl__.cmap[key5] = w4.__owl__.id;
* *
* // _prepare is called, to basically call willStart, then render the * // __prepare is called, to basically call willStart, then render the
* // component * // component
* def3 = w4._prepare(); * def3 = w4.__prepare();
* *
* def3 = def3.then(vnode => { * def3 = def3.then(vnode => {
* // we create here a virtual node for the parent (NOT the component). This * // we create here a virtual node for the parent (NOT the component). This
@@ -301,11 +301,11 @@ const T_COMPONENT_MODS_CODE = Object.assign({}, MODS_CODE, {
* // component at the proper time * // component at the proper time
* pvnode.data.hook = { * pvnode.data.hook = {
* insert(vn) { * insert(vn) {
* // the _mount method will patch the component vdom into the elm vn.elm, * // the __mount method will patch the component vdom into the elm vn.elm,
* // then call the mounted hooks. However, suprisingly, the snabbdom * // then call the mounted hooks. However, suprisingly, the snabbdom
* // patch method actually replace the elm by a new elm, so we need * // patch method actually replace the elm by a new elm, so we need
* // to synchronise the pvnode elm with the resulting elm * // to synchronise the pvnode elm with the resulting elm
* let nvn = w4._mount(vnode, vn.elm); * let nvn = w4.__mount(vnode, vn.elm);
* pvnode.elm = nvn.elm; * pvnode.elm = nvn.elm;
* // what follows is only present if there are animations on the component * // what follows is only present if there are animations on the component
* utils.transitionInsert(vn, "fade"); * utils.transitionInsert(vn, "fade");
@@ -333,10 +333,10 @@ const T_COMPONENT_MODS_CODE = Object.assign({}, MODS_CODE, {
* }); * });
* } else { * } else {
* // this is the 'update' path of the directive. * // this is the 'update' path of the directive.
* // the call to _updateProps is the actual component update * // the call to __updateProps is the actual component update
* // Note that we only update the props if we cannot reuse the previous * // Note that we only update the props if we cannot reuse the previous
* // rendering work (in the case it was rendered with the same props) * // rendering work (in the case it was rendered with the same props)
* def3 = def3 || w4._updateProps(props4, extra.forceUpdate, extra.patchQueue); * def3 = def3 || w4.__updateProps(props4, extra.forceUpdate, extra.patchQueue);
* def3 = def3.then(() => { * def3 = def3.then(() => {
* // if component was destroyed in the meantime, we do nothing (so, this * // if component was destroyed in the meantime, we do nothing (so, this
* // means that the parent's element children list will have a null in * // means that the parent's element children list will have a null in
@@ -606,10 +606,10 @@ QWeb.addDirective({
} }
} }
ctx.addLine(`def${defID} = w${componentID}._prepare();`); ctx.addLine(`def${defID} = w${componentID}.__prepare();`);
// hack: specify empty remove hook to prevent the node from being removed from the DOM // hack: specify empty remove hook to prevent the node from being removed from the DOM
ctx.addLine( ctx.addLine(
`def${defID} = def${defID}.then(vnode=>{${createHook}let pvnode=h(vnode.sel, {key: ${templateID}, hook: {insert(vn) {let nvn=w${componentID}._mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;${refExpr}${transitionsInsertCode}},remove() {},destroy(vn) {${finalizeComponentCode}}}});c${ `def${defID} = def${defID}.then(vnode=>{${createHook}let pvnode=h(vnode.sel, {key: ${templateID}, hook: {insert(vn) {let nvn=w${componentID}.__mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;${refExpr}${transitionsInsertCode}},remove() {},destroy(vn) {${finalizeComponentCode}}}});c${
ctx.parentNode ctx.parentNode
}[_${dummyID}_index]=pvnode;w${componentID}.__owl__.pvnode = pvnode;});` }[_${dummyID}_index]=pvnode;w${componentID}.__owl__.pvnode = pvnode;});`
); );
@@ -620,11 +620,11 @@ QWeb.addDirective({
? `patchQueue${componentID}` ? `patchQueue${componentID}`
: "extra.patchQueue"; : "extra.patchQueue";
ctx.addLine( ctx.addLine(
`def${defID} = def${defID} || w${componentID}._updateProps(props${componentID}, extra.forceUpdate, ${patchQueueCode});` `def${defID} = def${defID} || w${componentID}.__updateProps(props${componentID}, extra.forceUpdate, ${patchQueueCode});`
); );
let keepAliveCode = ""; let keepAliveCode = "";
if (keepAlive) { if (keepAlive) {
keepAliveCode = `pvnode.data.hook.insert = vn => {vn.elm.parentNode.replaceChild(w${componentID}.el,vn.elm);vn.elm=w${componentID}.el;w${componentID}._remount();};`; keepAliveCode = `pvnode.data.hook.insert = vn => {vn.elm.parentNode.replaceChild(w${componentID}.el,vn.elm);vn.elm=w${componentID}.el;w${componentID}.__remount();};`;
} }
ctx.addLine( ctx.addLine(
`def${defID} = def${defID}.then(()=>{if (w${componentID}.__owl__.isDestroyed) {return};${ `def${defID} = def${defID}.then(()=>{if (w${componentID}.__owl__.isDestroyed) {return};${
@@ -637,7 +637,7 @@ QWeb.addDirective({
if (async) { if (async) {
ctx.addLine( ctx.addLine(
`def${defID}.then(w${componentID}._applyPatchQueue.bind(w${componentID}, patchQueue${componentID}));` `def${defID}.then(w${componentID}.__applyPatchQueue.bind(w${componentID}, patchQueue${componentID}));`
); );
} else { } else {
ctx.addLine(`extra.promises.push(def${defID});`); ctx.addLine(`extra.promises.push(def${defID});`);
+5 -5
View File
@@ -230,9 +230,9 @@ export function connect<E extends EnvWithStore, P, S>(
* updates to be called for the parents before the children. However, * updates to be called for the parents before the children. However,
* if we use the mounted hook, this will be done in the reverse order. * if we use the mounted hook, this will be done in the reverse order.
*/ */
_callMounted() { __callMounted() {
(<any>this.__owl__).store.on("update", this, this._checkUpdate); (<any>this.__owl__).store.on("update", this, this._checkUpdate);
super._callMounted(); super.__callMounted();
} }
willUnmount() { willUnmount() {
(<any>this.__owl__).store.off("update", this); (<any>this.__owl__).store.off("update", this);
@@ -265,10 +265,10 @@ export function connect<E extends EnvWithStore, P, S>(
} }
if (didChange) { if (didChange) {
(<any>this.__owl__).currentStoreProps = storeProps; (<any>this.__owl__).currentStoreProps = storeProps;
this._updateProps(ownProps, false); this.__updateProps(ownProps, false);
} }
} }
_updateProps(nextProps, forceUpdate, patchQueue?: any[]) { __updateProps(nextProps, forceUpdate, patchQueue?: any[]) {
if ((<any>this.__owl__).ownProps !== nextProps) { if ((<any>this.__owl__).ownProps !== nextProps) {
(<any>this.__owl__).currentStoreProps = mapStoreToProps( (<any>this.__owl__).currentStoreProps = mapStoreToProps(
(<any>this.__owl__).store.state, (<any>this.__owl__).store.state,
@@ -282,7 +282,7 @@ export function connect<E extends EnvWithStore, P, S>(
nextProps, nextProps,
(<any>this.__owl__).currentStoreProps (<any>this.__owl__).currentStoreProps
); );
return super._updateProps(mergedProps, forceUpdate, patchQueue); return super.__updateProps(mergedProps, forceUpdate, patchQueue);
} }
}; };
+6 -6
View File
@@ -29,13 +29,13 @@ exports[`animations t-transition combined with component 1`] = `
if (!W4) {throw new Error('Cannot find the definition of component \\"' + componentKey4 + '\\"')} if (!W4) {throw new Error('Cannot find the definition of component \\"' + componentKey4 + '\\"')}
w4 = new W4(owner, props4); w4 = new W4(owner, props4);
context.__owl__.cmap[4] = w4.__owl__.id; context.__owl__.cmap[4] = w4.__owl__.id;
def3 = w4._prepare(); def3 = w4.__prepare();
def3 = def3.then(vnode=>{let pvnode=h(vnode.sel, {key: 4, hook: {insert(vn) {let nvn=w4._mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;utils.transitionInsert(vn, 'chimay');},remove() {},destroy(vn) {let finalize = () => { def3 = def3.then(vnode=>{let pvnode=h(vnode.sel, {key: 4, hook: {insert(vn) {let nvn=w4.__mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;utils.transitionInsert(vn, 'chimay');},remove() {},destroy(vn) {let finalize = () => {
w4.destroy(); w4.destroy();
}; };
utils.transitionRemove(vn, 'chimay', finalize);}}});c1[_2_index]=pvnode;w4.__owl__.pvnode = pvnode;}); utils.transitionRemove(vn, 'chimay', finalize);}}});c1[_2_index]=pvnode;w4.__owl__.pvnode = pvnode;});
} else { } else {
def3 = def3 || w4._updateProps(props4, extra.forceUpdate, extra.patchQueue); def3 = 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;}); def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;});
} }
extra.promises.push(def3); extra.promises.push(def3);
@@ -73,13 +73,13 @@ exports[`animations t-transition combined with t-component and t-if 1`] = `
if (!W4) {throw new Error('Cannot find the definition of component \\"' + componentKey4 + '\\"')} if (!W4) {throw new Error('Cannot find the definition of component \\"' + componentKey4 + '\\"')}
w4 = new W4(owner, props4); w4 = new W4(owner, props4);
context.__owl__.cmap[4] = w4.__owl__.id; context.__owl__.cmap[4] = w4.__owl__.id;
def3 = w4._prepare(); def3 = w4.__prepare();
def3 = def3.then(vnode=>{let pvnode=h(vnode.sel, {key: 4, hook: {insert(vn) {let nvn=w4._mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;utils.transitionInsert(vn, 'chimay');},remove() {},destroy(vn) {let finalize = () => { def3 = def3.then(vnode=>{let pvnode=h(vnode.sel, {key: 4, hook: {insert(vn) {let nvn=w4.__mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;utils.transitionInsert(vn, 'chimay');},remove() {},destroy(vn) {let finalize = () => {
w4.destroy(); w4.destroy();
}; };
utils.transitionRemove(vn, 'chimay', finalize);}}});c1[_2_index]=pvnode;w4.__owl__.pvnode = pvnode;}); utils.transitionRemove(vn, 'chimay', finalize);}}});c1[_2_index]=pvnode;w4.__owl__.pvnode = pvnode;});
} else { } else {
def3 = def3 || w4._updateProps(props4, extra.forceUpdate, extra.patchQueue); def3 = 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;}); def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;});
} }
extra.promises.push(def3); extra.promises.push(def3);
+69 -69
View File
@@ -42,10 +42,10 @@ exports[`async rendering delayed component with t-asyncroot directive 1`] = `
if (!W7) {throw new Error('Cannot find the definition of component \\"' + componentKey7 + '\\"')} if (!W7) {throw new Error('Cannot find the definition of component \\"' + componentKey7 + '\\"')}
w7 = new W7(owner, props7); w7 = new W7(owner, props7);
context.__owl__.cmap[7] = w7.__owl__.id; context.__owl__.cmap[7] = w7.__owl__.id;
def6 = w7._prepare(); def6 = w7.__prepare();
def6 = def6.then(vnode=>{let pvnode=h(vnode.sel, {key: 7, hook: {insert(vn) {let nvn=w7._mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;},remove() {},destroy(vn) {w7.destroy();}}});c4[_5_index]=pvnode;w7.__owl__.pvnode = pvnode;}); def6 = def6.then(vnode=>{let pvnode=h(vnode.sel, {key: 7, hook: {insert(vn) {let nvn=w7.__mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;},remove() {},destroy(vn) {w7.destroy();}}});c4[_5_index]=pvnode;w7.__owl__.pvnode = pvnode;});
} else { } else {
def6 = def6 || w7._updateProps(props7, extra.forceUpdate, extra.patchQueue); def6 = def6 || w7.__updateProps(props7, extra.forceUpdate, extra.patchQueue);
def6 = def6.then(()=>{if (w7.__owl__.isDestroyed) {return};let pvnode=w7.__owl__.pvnode;c4[_5_index]=pvnode;}); def6 = def6.then(()=>{if (w7.__owl__.isDestroyed) {return};let pvnode=w7.__owl__.pvnode;c4[_5_index]=pvnode;});
} }
extra.promises.push(def6); extra.promises.push(def6);
@@ -70,13 +70,13 @@ exports[`async rendering delayed component with t-asyncroot directive 1`] = `
if (!W10) {throw new Error('Cannot find the definition of component \\"' + componentKey10 + '\\"')} if (!W10) {throw new Error('Cannot find the definition of component \\"' + componentKey10 + '\\"')}
w10 = new W10(owner, props10); w10 = new W10(owner, props10);
context.__owl__.cmap[10] = w10.__owl__.id; context.__owl__.cmap[10] = w10.__owl__.id;
def9 = w10._prepare(); def9 = w10.__prepare();
def9 = def9.then(vnode=>{let pvnode=h(vnode.sel, {key: 10, hook: {insert(vn) {let nvn=w10._mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;},remove() {},destroy(vn) {w10.destroy();}}});c4[_8_index]=pvnode;w10.__owl__.pvnode = pvnode;}); def9 = def9.then(vnode=>{let pvnode=h(vnode.sel, {key: 10, hook: {insert(vn) {let nvn=w10.__mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;},remove() {},destroy(vn) {w10.destroy();}}});c4[_8_index]=pvnode;w10.__owl__.pvnode = pvnode;});
} else { } else {
def9 = def9 || w10._updateProps(props10, extra.forceUpdate, patchQueue10); def9 = def9 || w10.__updateProps(props10, extra.forceUpdate, patchQueue10);
def9 = def9.then(()=>{if (w10.__owl__.isDestroyed) {return};let pvnode=w10.__owl__.pvnode;c4[_8_index]=pvnode;}); def9 = def9.then(()=>{if (w10.__owl__.isDestroyed) {return};let pvnode=w10.__owl__.pvnode;c4[_8_index]=pvnode;});
} }
def9.then(w10._applyPatchQueue.bind(w10, patchQueue10)); def9.then(w10.__applyPatchQueue.bind(w10, patchQueue10));
return vn1; return vn1;
}" }"
`; `;
@@ -124,13 +124,13 @@ exports[`async rendering fast component with t-asyncroot directive 1`] = `
if (!W7) {throw new Error('Cannot find the definition of component \\"' + componentKey7 + '\\"')} if (!W7) {throw new Error('Cannot find the definition of component \\"' + componentKey7 + '\\"')}
w7 = new W7(owner, props7); w7 = new W7(owner, props7);
context.__owl__.cmap[7] = w7.__owl__.id; context.__owl__.cmap[7] = w7.__owl__.id;
def6 = w7._prepare(); def6 = w7.__prepare();
def6 = def6.then(vnode=>{let pvnode=h(vnode.sel, {key: 7, hook: {insert(vn) {let nvn=w7._mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;},remove() {},destroy(vn) {w7.destroy();}}});c4[_5_index]=pvnode;w7.__owl__.pvnode = pvnode;}); def6 = def6.then(vnode=>{let pvnode=h(vnode.sel, {key: 7, hook: {insert(vn) {let nvn=w7.__mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;},remove() {},destroy(vn) {w7.destroy();}}});c4[_5_index]=pvnode;w7.__owl__.pvnode = pvnode;});
} else { } else {
def6 = def6 || w7._updateProps(props7, extra.forceUpdate, patchQueue7); def6 = def6 || w7.__updateProps(props7, extra.forceUpdate, patchQueue7);
def6 = def6.then(()=>{if (w7.__owl__.isDestroyed) {return};let pvnode=w7.__owl__.pvnode;c4[_5_index]=pvnode;}); def6 = def6.then(()=>{if (w7.__owl__.isDestroyed) {return};let pvnode=w7.__owl__.pvnode;c4[_5_index]=pvnode;});
} }
def6.then(w7._applyPatchQueue.bind(w7, patchQueue7)); def6.then(w7.__applyPatchQueue.bind(w7, patchQueue7));
//COMPONENT //COMPONENT
let def9; let def9;
let w10 = 10 in context.__owl__.cmap ? context.__owl__.children[context.__owl__.cmap[10]] : false; let w10 = 10 in context.__owl__.cmap ? context.__owl__.children[context.__owl__.cmap[10]] : false;
@@ -151,10 +151,10 @@ exports[`async rendering fast component with t-asyncroot directive 1`] = `
if (!W10) {throw new Error('Cannot find the definition of component \\"' + componentKey10 + '\\"')} if (!W10) {throw new Error('Cannot find the definition of component \\"' + componentKey10 + '\\"')}
w10 = new W10(owner, props10); w10 = new W10(owner, props10);
context.__owl__.cmap[10] = w10.__owl__.id; context.__owl__.cmap[10] = w10.__owl__.id;
def9 = w10._prepare(); def9 = w10.__prepare();
def9 = def9.then(vnode=>{let pvnode=h(vnode.sel, {key: 10, hook: {insert(vn) {let nvn=w10._mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;},remove() {},destroy(vn) {w10.destroy();}}});c4[_8_index]=pvnode;w10.__owl__.pvnode = pvnode;}); def9 = def9.then(vnode=>{let pvnode=h(vnode.sel, {key: 10, hook: {insert(vn) {let nvn=w10.__mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;},remove() {},destroy(vn) {w10.destroy();}}});c4[_8_index]=pvnode;w10.__owl__.pvnode = pvnode;});
} else { } else {
def9 = def9 || w10._updateProps(props10, extra.forceUpdate, extra.patchQueue); def9 = def9 || w10.__updateProps(props10, extra.forceUpdate, extra.patchQueue);
def9 = def9.then(()=>{if (w10.__owl__.isDestroyed) {return};let pvnode=w10.__owl__.pvnode;c4[_8_index]=pvnode;}); def9 = def9.then(()=>{if (w10.__owl__.isDestroyed) {return};let pvnode=w10.__owl__.pvnode;c4[_8_index]=pvnode;});
} }
extra.promises.push(def9); extra.promises.push(def9);
@@ -204,10 +204,10 @@ exports[`async rendering t-component with t-asyncroot directive: mixed re-render
if (!W7) {throw new Error('Cannot find the definition of component \\"' + componentKey7 + '\\"')} if (!W7) {throw new Error('Cannot find the definition of component \\"' + componentKey7 + '\\"')}
w7 = new W7(owner, props7); w7 = new W7(owner, props7);
context.__owl__.cmap[7] = w7.__owl__.id; context.__owl__.cmap[7] = w7.__owl__.id;
def6 = w7._prepare(); def6 = w7.__prepare();
def6 = def6.then(vnode=>{let pvnode=h(vnode.sel, {key: 7, hook: {insert(vn) {let nvn=w7._mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;},remove() {},destroy(vn) {w7.destroy();}}});c4[_5_index]=pvnode;w7.__owl__.pvnode = pvnode;}); def6 = def6.then(vnode=>{let pvnode=h(vnode.sel, {key: 7, hook: {insert(vn) {let nvn=w7.__mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;},remove() {},destroy(vn) {w7.destroy();}}});c4[_5_index]=pvnode;w7.__owl__.pvnode = pvnode;});
} else { } else {
def6 = def6 || w7._updateProps(props7, extra.forceUpdate, extra.patchQueue); def6 = def6 || w7.__updateProps(props7, extra.forceUpdate, extra.patchQueue);
def6 = def6.then(()=>{if (w7.__owl__.isDestroyed) {return};let pvnode=w7.__owl__.pvnode;c4[_5_index]=pvnode;}); def6 = def6.then(()=>{if (w7.__owl__.isDestroyed) {return};let pvnode=w7.__owl__.pvnode;c4[_5_index]=pvnode;});
} }
extra.promises.push(def6); extra.promises.push(def6);
@@ -232,13 +232,13 @@ exports[`async rendering t-component with t-asyncroot directive: mixed re-render
if (!W10) {throw new Error('Cannot find the definition of component \\"' + componentKey10 + '\\"')} if (!W10) {throw new Error('Cannot find the definition of component \\"' + componentKey10 + '\\"')}
w10 = new W10(owner, props10); w10 = new W10(owner, props10);
context.__owl__.cmap[10] = w10.__owl__.id; context.__owl__.cmap[10] = w10.__owl__.id;
def9 = w10._prepare(); def9 = w10.__prepare();
def9 = def9.then(vnode=>{let pvnode=h(vnode.sel, {key: 10, hook: {insert(vn) {let nvn=w10._mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;},remove() {},destroy(vn) {w10.destroy();}}});c4[_8_index]=pvnode;w10.__owl__.pvnode = pvnode;}); def9 = def9.then(vnode=>{let pvnode=h(vnode.sel, {key: 10, hook: {insert(vn) {let nvn=w10.__mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;},remove() {},destroy(vn) {w10.destroy();}}});c4[_8_index]=pvnode;w10.__owl__.pvnode = pvnode;});
} else { } else {
def9 = def9 || w10._updateProps(props10, extra.forceUpdate, patchQueue10); def9 = def9 || w10.__updateProps(props10, extra.forceUpdate, patchQueue10);
def9 = def9.then(()=>{if (w10.__owl__.isDestroyed) {return};let pvnode=w10.__owl__.pvnode;c4[_8_index]=pvnode;}); def9 = def9.then(()=>{if (w10.__owl__.isDestroyed) {return};let pvnode=w10.__owl__.pvnode;c4[_8_index]=pvnode;});
} }
def9.then(w10._applyPatchQueue.bind(w10, patchQueue10)); def9.then(w10.__applyPatchQueue.bind(w10, patchQueue10));
return vn1; return vn1;
}" }"
`; `;
@@ -273,10 +273,10 @@ exports[`class and style attributes with t-component dynamic t-att-style is prop
if (!W4) {throw new Error('Cannot find the definition of component \\"' + componentKey4 + '\\"')} if (!W4) {throw new Error('Cannot find the definition of component \\"' + componentKey4 + '\\"')}
w4 = new W4(owner, props4); w4 = new W4(owner, props4);
context.__owl__.cmap[4] = w4.__owl__.id; context.__owl__.cmap[4] = w4.__owl__.id;
def3 = w4._prepare(); def3 = w4.__prepare();
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, pvnode.elm);pvnode.elm=nvn.elm;},remove() {},destroy(vn) {w4.destroy();}}});c1[_2_index]=pvnode;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, pvnode.elm);pvnode.elm=nvn.elm;},remove() {},destroy(vn) {w4.destroy();}}});c1[_2_index]=pvnode;w4.__owl__.pvnode = pvnode;});
} else { } else {
def3 = def3 || w4._updateProps(props4, extra.forceUpdate, extra.patchQueue); def3 = 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;}); 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); extra.promises.push(def3);
@@ -314,14 +314,14 @@ exports[`class and style attributes with t-component t-att-class is properly add
if (!W4) {throw new Error('Cannot find the definition of component \\"' + componentKey4 + '\\"')} if (!W4) {throw new Error('Cannot find the definition of component \\"' + componentKey4 + '\\"')}
w4 = new W4(owner, props4); w4 = new W4(owner, props4);
context.__owl__.cmap[4] = w4.__owl__.id; context.__owl__.cmap[4] = w4.__owl__.id;
def3 = w4._prepare(); def3 = w4.__prepare();
def3 = def3.then(vnode=>{vnode.data.hook = {create(_, vn){for (let k in _5) { def3 = def3.then(vnode=>{vnode.data.hook = {create(_, vn){for (let k in _5) {
if (_5[k]) { if (_5[k]) {
vn.elm.classList.add(k); vn.elm.classList.add(k);
} }
}}};let pvnode=h(vnode.sel, {key: 4, hook: {insert(vn) {let nvn=w4._mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;},remove() {},destroy(vn) {w4.destroy();}}});c1[_2_index]=pvnode;w4.__owl__.pvnode = pvnode;}); }}};let pvnode=h(vnode.sel, {key: 4, hook: {insert(vn) {let nvn=w4.__mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;},remove() {},destroy(vn) {w4.destroy();}}});c1[_2_index]=pvnode;w4.__owl__.pvnode = pvnode;});
} else { } else {
def3 = def3 || w4._updateProps(props4, extra.forceUpdate, extra.patchQueue); def3 = 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;}); 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); extra.promises.push(def3);
@@ -374,10 +374,10 @@ exports[`composition sub components with some state rendered in a loop 1`] = `
if (!W7) {throw new Error('Cannot find the definition of component \\"' + componentKey7 + '\\"')} if (!W7) {throw new Error('Cannot find the definition of component \\"' + componentKey7 + '\\"')}
w7 = new W7(owner, props7); w7 = new W7(owner, props7);
context.__owl__.cmap[key8] = w7.__owl__.id; context.__owl__.cmap[key8] = w7.__owl__.id;
def6 = w7._prepare(); def6 = w7.__prepare();
def6 = def6.then(vnode=>{let pvnode=h(vnode.sel, {key: key8, hook: {insert(vn) {let nvn=w7._mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;},remove() {},destroy(vn) {w7.destroy();}}});c1[_5_index]=pvnode;w7.__owl__.pvnode = pvnode;}); def6 = def6.then(vnode=>{let pvnode=h(vnode.sel, {key: key8, hook: {insert(vn) {let nvn=w7.__mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;},remove() {},destroy(vn) {w7.destroy();}}});c1[_5_index]=pvnode;w7.__owl__.pvnode = pvnode;});
} else { } else {
def6 = def6 || w7._updateProps(props7, extra.forceUpdate, extra.patchQueue); def6 = 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;}); def6 = def6.then(()=>{if (w7.__owl__.isDestroyed) {return};let pvnode=w7.__owl__.pvnode;c1[_5_index]=pvnode;});
} }
extra.promises.push(def6); extra.promises.push(def6);
@@ -415,10 +415,10 @@ exports[`composition t-component with dynamic value 1`] = `
if (!W4) {throw new Error('Cannot find the definition of component \\"' + componentKey4 + '\\"')} if (!W4) {throw new Error('Cannot find the definition of component \\"' + componentKey4 + '\\"')}
w4 = new W4(owner, props4); w4 = new W4(owner, props4);
context.__owl__.cmap[4] = w4.__owl__.id; context.__owl__.cmap[4] = w4.__owl__.id;
def3 = w4._prepare(); def3 = w4.__prepare();
def3 = def3.then(vnode=>{let pvnode=h(vnode.sel, {key: 4, hook: {insert(vn) {let nvn=w4._mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;},remove() {},destroy(vn) {w4.destroy();}}});c1[_2_index]=pvnode;w4.__owl__.pvnode = pvnode;}); def3 = def3.then(vnode=>{let pvnode=h(vnode.sel, {key: 4, hook: {insert(vn) {let nvn=w4.__mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;},remove() {},destroy(vn) {w4.destroy();}}});c1[_2_index]=pvnode;w4.__owl__.pvnode = pvnode;});
} else { } else {
def3 = def3 || w4._updateProps(props4, extra.forceUpdate, extra.patchQueue); def3 = 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;}); def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;});
} }
extra.promises.push(def3); extra.promises.push(def3);
@@ -455,10 +455,10 @@ exports[`composition t-component with dynamic value 2 1`] = `
if (!W4) {throw new Error('Cannot find the definition of component \\"' + componentKey4 + '\\"')} if (!W4) {throw new Error('Cannot find the definition of component \\"' + componentKey4 + '\\"')}
w4 = new W4(owner, props4); w4 = new W4(owner, props4);
context.__owl__.cmap[4] = w4.__owl__.id; context.__owl__.cmap[4] = w4.__owl__.id;
def3 = w4._prepare(); def3 = w4.__prepare();
def3 = def3.then(vnode=>{let pvnode=h(vnode.sel, {key: 4, hook: {insert(vn) {let nvn=w4._mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;},remove() {},destroy(vn) {w4.destroy();}}});c1[_2_index]=pvnode;w4.__owl__.pvnode = pvnode;}); def3 = def3.then(vnode=>{let pvnode=h(vnode.sel, {key: 4, hook: {insert(vn) {let nvn=w4.__mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;},remove() {},destroy(vn) {w4.destroy();}}});c1[_2_index]=pvnode;w4.__owl__.pvnode = pvnode;});
} else { } else {
def3 = def3 || w4._updateProps(props4, extra.forceUpdate, extra.patchQueue); def3 = 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;}); def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;});
} }
extra.promises.push(def3); extra.promises.push(def3);
@@ -495,10 +495,10 @@ exports[`other directives with t-component t-on with handler bound to argument 1
if (!W4) {throw new Error('Cannot find the definition of component \\"' + componentKey4 + '\\"')} if (!W4) {throw new Error('Cannot find the definition of component \\"' + componentKey4 + '\\"')}
w4 = new W4(owner, props4); w4 = new W4(owner, props4);
context.__owl__.cmap[4] = w4.__owl__.id; context.__owl__.cmap[4] = w4.__owl__.id;
def3 = w4._prepare(); def3 = w4.__prepare();
def3 = def3.then(vnode=>{vnode.data.hook = {create(_, vn){vn.elm.addEventListener('ev', owner['onEv'].bind(owner, 3));}};let pvnode=h(vnode.sel, {key: 4, hook: {insert(vn) {let nvn=w4._mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;},remove() {},destroy(vn) {w4.destroy();}}});c1[_2_index]=pvnode;w4.__owl__.pvnode = pvnode;}); def3 = def3.then(vnode=>{vnode.data.hook = {create(_, vn){vn.elm.addEventListener('ev', owner['onEv'].bind(owner, 3));}};let pvnode=h(vnode.sel, {key: 4, hook: {insert(vn) {let nvn=w4.__mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;},remove() {},destroy(vn) {w4.destroy();}}});c1[_2_index]=pvnode;w4.__owl__.pvnode = pvnode;});
} else { } else {
def3 = def3 || w4._updateProps(props4, extra.forceUpdate, extra.patchQueue); def3 = 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;}); def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;});
} }
extra.promises.push(def3); extra.promises.push(def3);
@@ -535,10 +535,10 @@ exports[`other directives with t-component t-on with handler bound to empty obje
if (!W4) {throw new Error('Cannot find the definition of component \\"' + componentKey4 + '\\"')} if (!W4) {throw new Error('Cannot find the definition of component \\"' + componentKey4 + '\\"')}
w4 = new W4(owner, props4); w4 = new W4(owner, props4);
context.__owl__.cmap[4] = w4.__owl__.id; context.__owl__.cmap[4] = w4.__owl__.id;
def3 = w4._prepare(); def3 = w4.__prepare();
def3 = def3.then(vnode=>{vnode.data.hook = {create(_, vn){vn.elm.addEventListener('ev', owner['onEv'].bind(owner, {}));}};let pvnode=h(vnode.sel, {key: 4, hook: {insert(vn) {let nvn=w4._mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;},remove() {},destroy(vn) {w4.destroy();}}});c1[_2_index]=pvnode;w4.__owl__.pvnode = pvnode;}); def3 = def3.then(vnode=>{vnode.data.hook = {create(_, vn){vn.elm.addEventListener('ev', owner['onEv'].bind(owner, {}));}};let pvnode=h(vnode.sel, {key: 4, hook: {insert(vn) {let nvn=w4.__mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;},remove() {},destroy(vn) {w4.destroy();}}});c1[_2_index]=pvnode;w4.__owl__.pvnode = pvnode;});
} else { } else {
def3 = def3 || w4._updateProps(props4, extra.forceUpdate, extra.patchQueue); def3 = 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;}); def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;});
} }
extra.promises.push(def3); extra.promises.push(def3);
@@ -575,10 +575,10 @@ exports[`other directives with t-component t-on with handler bound to empty obje
if (!W4) {throw new Error('Cannot find the definition of component \\"' + componentKey4 + '\\"')} if (!W4) {throw new Error('Cannot find the definition of component \\"' + componentKey4 + '\\"')}
w4 = new W4(owner, props4); w4 = new W4(owner, props4);
context.__owl__.cmap[4] = w4.__owl__.id; context.__owl__.cmap[4] = w4.__owl__.id;
def3 = w4._prepare(); def3 = w4.__prepare();
def3 = def3.then(vnode=>{vnode.data.hook = {create(_, vn){vn.elm.addEventListener('ev', owner['onEv'].bind(owner, {}));}};let pvnode=h(vnode.sel, {key: 4, hook: {insert(vn) {let nvn=w4._mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;},remove() {},destroy(vn) {w4.destroy();}}});c1[_2_index]=pvnode;w4.__owl__.pvnode = pvnode;}); def3 = def3.then(vnode=>{vnode.data.hook = {create(_, vn){vn.elm.addEventListener('ev', owner['onEv'].bind(owner, {}));}};let pvnode=h(vnode.sel, {key: 4, hook: {insert(vn) {let nvn=w4.__mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;},remove() {},destroy(vn) {w4.destroy();}}});c1[_2_index]=pvnode;w4.__owl__.pvnode = pvnode;});
} else { } else {
def3 = def3 || w4._updateProps(props4, extra.forceUpdate, extra.patchQueue); def3 = 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;}); def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;});
} }
extra.promises.push(def3); extra.promises.push(def3);
@@ -615,10 +615,10 @@ exports[`other directives with t-component t-on with handler bound to object 1`]
if (!W4) {throw new Error('Cannot find the definition of component \\"' + componentKey4 + '\\"')} if (!W4) {throw new Error('Cannot find the definition of component \\"' + componentKey4 + '\\"')}
w4 = new W4(owner, props4); w4 = new W4(owner, props4);
context.__owl__.cmap[4] = w4.__owl__.id; context.__owl__.cmap[4] = w4.__owl__.id;
def3 = w4._prepare(); def3 = w4.__prepare();
def3 = def3.then(vnode=>{vnode.data.hook = {create(_, vn){vn.elm.addEventListener('ev', owner['onEv'].bind(owner, {val:3}));}};let pvnode=h(vnode.sel, {key: 4, hook: {insert(vn) {let nvn=w4._mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;},remove() {},destroy(vn) {w4.destroy();}}});c1[_2_index]=pvnode;w4.__owl__.pvnode = pvnode;}); def3 = def3.then(vnode=>{vnode.data.hook = {create(_, vn){vn.elm.addEventListener('ev', owner['onEv'].bind(owner, {val:3}));}};let pvnode=h(vnode.sel, {key: 4, hook: {insert(vn) {let nvn=w4.__mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;},remove() {},destroy(vn) {w4.destroy();}}});c1[_2_index]=pvnode;w4.__owl__.pvnode = pvnode;});
} else { } else {
def3 = def3 || w4._updateProps(props4, extra.forceUpdate, extra.patchQueue); def3 = 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;}); def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;});
} }
extra.promises.push(def3); extra.promises.push(def3);
@@ -655,10 +655,10 @@ exports[`other directives with t-component t-on with prevent and self modifiers
if (!W4) {throw new Error('Cannot find the definition of component \\"' + componentKey4 + '\\"')} if (!W4) {throw new Error('Cannot find the definition of component \\"' + componentKey4 + '\\"')}
w4 = new W4(owner, props4); w4 = new W4(owner, props4);
context.__owl__.cmap[4] = w4.__owl__.id; context.__owl__.cmap[4] = w4.__owl__.id;
def3 = w4._prepare(); def3 = w4.__prepare();
def3 = def3.then(vnode=>{vnode.data.hook = {create(_, vn){vn.elm.addEventListener('ev', function (e) {e.preventDefault();if (e.target !== vn.elm) {return}owner['onEv'].call(owner, e);});}};let pvnode=h(vnode.sel, {key: 4, hook: {insert(vn) {let nvn=w4._mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;},remove() {},destroy(vn) {w4.destroy();}}});c1[_2_index]=pvnode;w4.__owl__.pvnode = pvnode;}); def3 = def3.then(vnode=>{vnode.data.hook = {create(_, vn){vn.elm.addEventListener('ev', function (e) {e.preventDefault();if (e.target !== vn.elm) {return}owner['onEv'].call(owner, e);});}};let pvnode=h(vnode.sel, {key: 4, hook: {insert(vn) {let nvn=w4.__mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;},remove() {},destroy(vn) {w4.destroy();}}});c1[_2_index]=pvnode;w4.__owl__.pvnode = pvnode;});
} else { } else {
def3 = def3 || w4._updateProps(props4, extra.forceUpdate, extra.patchQueue); def3 = 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;}); def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;});
} }
extra.promises.push(def3); extra.promises.push(def3);
@@ -695,10 +695,10 @@ exports[`other directives with t-component t-on with self and prevent modifiers
if (!W4) {throw new Error('Cannot find the definition of component \\"' + componentKey4 + '\\"')} if (!W4) {throw new Error('Cannot find the definition of component \\"' + componentKey4 + '\\"')}
w4 = new W4(owner, props4); w4 = new W4(owner, props4);
context.__owl__.cmap[4] = w4.__owl__.id; context.__owl__.cmap[4] = w4.__owl__.id;
def3 = w4._prepare(); def3 = w4.__prepare();
def3 = def3.then(vnode=>{vnode.data.hook = {create(_, vn){vn.elm.addEventListener('ev', function (e) {if (e.target !== vn.elm) {return}e.preventDefault();owner['onEv'].call(owner, e);});}};let pvnode=h(vnode.sel, {key: 4, hook: {insert(vn) {let nvn=w4._mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;},remove() {},destroy(vn) {w4.destroy();}}});c1[_2_index]=pvnode;w4.__owl__.pvnode = pvnode;}); def3 = def3.then(vnode=>{vnode.data.hook = {create(_, vn){vn.elm.addEventListener('ev', function (e) {if (e.target !== vn.elm) {return}e.preventDefault();owner['onEv'].call(owner, e);});}};let pvnode=h(vnode.sel, {key: 4, hook: {insert(vn) {let nvn=w4.__mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;},remove() {},destroy(vn) {w4.destroy();}}});c1[_2_index]=pvnode;w4.__owl__.pvnode = pvnode;});
} else { } else {
def3 = def3 || w4._updateProps(props4, extra.forceUpdate, extra.patchQueue); def3 = 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;}); def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;});
} }
extra.promises.push(def3); extra.promises.push(def3);
@@ -735,10 +735,10 @@ exports[`other directives with t-component t-on with self modifier 1`] = `
if (!W4) {throw new Error('Cannot find the definition of component \\"' + componentKey4 + '\\"')} if (!W4) {throw new Error('Cannot find the definition of component \\"' + componentKey4 + '\\"')}
w4 = new W4(owner, props4); w4 = new W4(owner, props4);
context.__owl__.cmap[4] = w4.__owl__.id; context.__owl__.cmap[4] = w4.__owl__.id;
def3 = w4._prepare(); def3 = w4.__prepare();
def3 = def3.then(vnode=>{vnode.data.hook = {create(_, vn){vn.elm.addEventListener('ev-1', owner['onEv1'].bind(owner));vn.elm.addEventListener('ev-2', function (e) {if (e.target !== vn.elm) {return}owner['onEv2'].call(owner, e);});}};let pvnode=h(vnode.sel, {key: 4, hook: {insert(vn) {let nvn=w4._mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;},remove() {},destroy(vn) {w4.destroy();}}});c1[_2_index]=pvnode;w4.__owl__.pvnode = pvnode;}); def3 = def3.then(vnode=>{vnode.data.hook = {create(_, vn){vn.elm.addEventListener('ev-1', owner['onEv1'].bind(owner));vn.elm.addEventListener('ev-2', function (e) {if (e.target !== vn.elm) {return}owner['onEv2'].call(owner, e);});}};let pvnode=h(vnode.sel, {key: 4, hook: {insert(vn) {let nvn=w4.__mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;},remove() {},destroy(vn) {w4.destroy();}}});c1[_2_index]=pvnode;w4.__owl__.pvnode = pvnode;});
} else { } else {
def3 = def3 || w4._updateProps(props4, extra.forceUpdate, extra.patchQueue); def3 = 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;}); def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;});
} }
extra.promises.push(def3); extra.promises.push(def3);
@@ -775,10 +775,10 @@ exports[`other directives with t-component t-on with stop and/or prevent modifie
if (!W4) {throw new Error('Cannot find the definition of component \\"' + componentKey4 + '\\"')} if (!W4) {throw new Error('Cannot find the definition of component \\"' + componentKey4 + '\\"')}
w4 = new W4(owner, props4); w4 = new W4(owner, props4);
context.__owl__.cmap[4] = w4.__owl__.id; context.__owl__.cmap[4] = w4.__owl__.id;
def3 = w4._prepare(); def3 = w4.__prepare();
def3 = def3.then(vnode=>{vnode.data.hook = {create(_, vn){vn.elm.addEventListener('ev-1', function (e) {e.stopPropagation();owner['onEv1'].call(owner, e);});vn.elm.addEventListener('ev-2', function (e) {e.preventDefault();owner['onEv2'].call(owner, e);});vn.elm.addEventListener('ev-3', function (e) {e.stopPropagation();e.preventDefault();owner['onEv3'].call(owner, e);});}};let pvnode=h(vnode.sel, {key: 4, hook: {insert(vn) {let nvn=w4._mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;},remove() {},destroy(vn) {w4.destroy();}}});c1[_2_index]=pvnode;w4.__owl__.pvnode = pvnode;}); def3 = def3.then(vnode=>{vnode.data.hook = {create(_, vn){vn.elm.addEventListener('ev-1', function (e) {e.stopPropagation();owner['onEv1'].call(owner, e);});vn.elm.addEventListener('ev-2', function (e) {e.preventDefault();owner['onEv2'].call(owner, e);});vn.elm.addEventListener('ev-3', function (e) {e.stopPropagation();e.preventDefault();owner['onEv3'].call(owner, e);});}};let pvnode=h(vnode.sel, {key: 4, hook: {insert(vn) {let nvn=w4.__mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;},remove() {},destroy(vn) {w4.destroy();}}});c1[_2_index]=pvnode;w4.__owl__.pvnode = pvnode;});
} else { } else {
def3 = def3 || w4._updateProps(props4, extra.forceUpdate, extra.patchQueue); def3 = 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;}); def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;});
} }
extra.promises.push(def3); extra.promises.push(def3);
@@ -816,10 +816,10 @@ exports[`random stuff/miscellaneous snapshotting compiled code 1`] = `
if (!W4) {throw new Error('Cannot find the definition of component \\"' + componentKey4 + '\\"')} if (!W4) {throw new Error('Cannot find the definition of component \\"' + componentKey4 + '\\"')}
w4 = new W4(owner, props4); w4 = new W4(owner, props4);
context.__owl__.cmap[key5] = w4.__owl__.id; context.__owl__.cmap[key5] = w4.__owl__.id;
def3 = w4._prepare(); def3 = w4.__prepare();
def3 = def3.then(vnode=>{let pvnode=h(vnode.sel, {key: key5, hook: {insert(vn) {let nvn=w4._mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;},remove() {},destroy(vn) {w4.destroy();}}});c1[_2_index]=pvnode;w4.__owl__.pvnode = pvnode;}); def3 = def3.then(vnode=>{let pvnode=h(vnode.sel, {key: key5, hook: {insert(vn) {let nvn=w4.__mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;},remove() {},destroy(vn) {w4.destroy();}}});c1[_2_index]=pvnode;w4.__owl__.pvnode = pvnode;});
} else { } else {
def3 = def3 || w4._updateProps(props4, extra.forceUpdate, extra.patchQueue); def3 = 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;}); def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;});
} }
extra.promises.push(def3); extra.promises.push(def3);
@@ -873,10 +873,10 @@ exports[`random stuff/miscellaneous t-on with handler bound to dynamic argument
if (!W7) {throw new Error('Cannot find the definition of component \\"' + componentKey7 + '\\"')} if (!W7) {throw new Error('Cannot find the definition of component \\"' + componentKey7 + '\\"')}
w7 = new W7(owner, props7); w7 = new W7(owner, props7);
context.__owl__.cmap[key8] = w7.__owl__.id; context.__owl__.cmap[key8] = w7.__owl__.id;
def6 = w7._prepare(); def6 = w7.__prepare();
def6 = def6.then(vnode=>{vnode.data.hook = {create(_, vn){vn.elm.addEventListener('ev', owner['onEv'].bind(owner, arg9));}};let pvnode=h(vnode.sel, {key: key8, hook: {insert(vn) {let nvn=w7._mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;},remove() {},destroy(vn) {w7.destroy();}}});c1[_5_index]=pvnode;w7.__owl__.pvnode = pvnode;}); def6 = def6.then(vnode=>{vnode.data.hook = {create(_, vn){vn.elm.addEventListener('ev', owner['onEv'].bind(owner, arg9));}};let pvnode=h(vnode.sel, {key: key8, hook: {insert(vn) {let nvn=w7.__mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;},remove() {},destroy(vn) {w7.destroy();}}});c1[_5_index]=pvnode;w7.__owl__.pvnode = pvnode;});
} else { } else {
def6 = def6 || w7._updateProps(props7, extra.forceUpdate, extra.patchQueue); def6 = 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;}); def6 = def6.then(()=>{if (w7.__owl__.isDestroyed) {return};let pvnode=w7.__owl__.pvnode;c1[_5_index]=pvnode;});
} }
extra.promises.push(def6); extra.promises.push(def6);
@@ -1062,10 +1062,10 @@ exports[`t-slot directive can define and call slots 1`] = `
w4 = new W4(owner, props4); w4 = new W4(owner, props4);
context.__owl__.cmap[4] = w4.__owl__.id; context.__owl__.cmap[4] = w4.__owl__.id;
w4.__owl__.slotId = 1; w4.__owl__.slotId = 1;
def3 = w4._prepare(); def3 = w4.__prepare();
def3 = def3.then(vnode=>{let pvnode=h(vnode.sel, {key: 4, hook: {insert(vn) {let nvn=w4._mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;},remove() {},destroy(vn) {w4.destroy();}}});c1[_2_index]=pvnode;w4.__owl__.pvnode = pvnode;}); def3 = def3.then(vnode=>{let pvnode=h(vnode.sel, {key: 4, hook: {insert(vn) {let nvn=w4.__mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;},remove() {},destroy(vn) {w4.destroy();}}});c1[_2_index]=pvnode;w4.__owl__.pvnode = pvnode;});
} else { } else {
def3 = def3 || w4._updateProps(props4, extra.forceUpdate, extra.patchQueue); def3 = 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;}); def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;});
} }
extra.promises.push(def3); extra.promises.push(def3);
+25 -25
View File
@@ -140,9 +140,9 @@ describe("basic widget properties", () => {
async willStart() { async willStart() {
this.state.drinks++; this.state.drinks++;
} }
async _render() { async __render() {
renderCalls++; renderCalls++;
return super._render(); return super.__render();
} }
} }
const widget = new TestW(env); const widget = new TestW(env);
@@ -1974,17 +1974,17 @@ describe("random stuff/miscellaneous", () => {
async willStart() { async willStart() {
steps.push(`${this.name}:willStart`); steps.push(`${this.name}:willStart`);
} }
_render(f, p) { __render(f, p) {
steps.push(`${this.name}:render`); steps.push(`${this.name}:render`);
return super._render(f, p); return super.__render(f, p);
} }
_patch(vnode) { __patch(vnode) {
steps.push(`${this.name}:_patch`); steps.push(`${this.name}:__patch`);
super._patch(vnode); super.__patch(vnode);
} }
_mount(vnode, elm) { __mount(vnode, elm) {
steps.push(`${this.name}:_patch(from _mount)`); steps.push(`${this.name}:__patch(from __mount)`);
return super._mount(vnode, elm); return super.__mount(vnode, elm);
} }
mounted() { mounted() {
steps.push(`${this.name}:mounted`); steps.push(`${this.name}:mounted`);
@@ -2085,11 +2085,11 @@ describe("random stuff/miscellaneous", () => {
"E:willStart", "E:willStart",
"D:render", "D:render",
"E:render", "E:render",
"A:_patch", "A:__patch",
"B:_patch(from _mount)", "B:__patch(from __mount)",
"C:_patch(from _mount)", "C:__patch(from __mount)",
"D:_patch(from _mount)", "D:__patch(from __mount)",
"E:_patch(from _mount)", "E:__patch(from __mount)",
"B:mounted", "B:mounted",
"D:mounted", "D:mounted",
"E:mounted", "E:mounted",
@@ -2110,12 +2110,12 @@ describe("random stuff/miscellaneous", () => {
"F:render", "F:render",
"C:willPatch", "C:willPatch",
"D:willPatch", "D:willPatch",
"C:_patch", "C:__patch",
"E:willUnmount", "E:willUnmount",
"E:destroy", "E:destroy",
"F:_patch(from _mount)", "F:__patch(from __mount)",
"F:mounted", "F:mounted",
"D:_patch", "D:__patch",
"D:patched", "D:patched",
"C:patched" "C:patched"
]); ]);
@@ -2232,8 +2232,8 @@ describe("async rendering", () => {
env.qweb.addTemplate("ChildA", `<span>a<t t-esc="props.val"/></span>`); env.qweb.addTemplate("ChildA", `<span>a<t t-esc="props.val"/></span>`);
class ChildA extends Widget { class ChildA extends Widget {
_updateProps(props, forceUpdate, fiber): Promise<void> { __updateProps(props, forceUpdate, fiber): Promise<void> {
return defA.then(() => super._updateProps(props, forceUpdate, fiber)); return defA.then(() => super.__updateProps(props, forceUpdate, fiber));
} }
} }
env.qweb.addTemplate("ChildB", `<span>b<t t-esc="props.val"/></span>`); env.qweb.addTemplate("ChildB", `<span>b<t t-esc="props.val"/></span>`);
@@ -2320,11 +2320,11 @@ describe("async rendering", () => {
components = { SubChild }; components = { SubChild };
mounted() { mounted() {
// from now on, each rendering in child widget will be delayed (see // from now on, each rendering in child widget will be delayed (see
// _render) // __render)
def = makeDeferred(); def = makeDeferred();
} }
async _render(f, p) { async __render(f, p) {
const result = await super._render(f, p); const result = await super.__render(f, p);
await def; await def;
return result; return result;
} }
@@ -2613,9 +2613,9 @@ describe("updating environment", () => {
test("updating widget env does not render widget (if not mounted)", async () => { test("updating widget env does not render widget (if not mounted)", async () => {
let n = 0; let n = 0;
class TestWidget extends Widget { class TestWidget extends Widget {
_render() { __render() {
n++; n++;
return super._render(); return super.__render();
} }
} }
+2 -2
View File
@@ -52,7 +52,7 @@ describe("props validation", () => {
} }
const w = new TestWidget(env, { message: "bottle" }); const w = new TestWidget(env, { message: "bottle" });
try { try {
await w._updateProps({}); await w.__updateProps({});
} catch (e) { } catch (e) {
expect(e.message).toBe("Missing props 'message' (component 'TestWidget')"); expect(e.message).toBe("Missing props 'message' (component 'TestWidget')");
} }
@@ -257,7 +257,7 @@ describe("default props", () => {
} }
const w = new TestWidget(env, {p: 1}); const w = new TestWidget(env, {p: 1});
await w._updateProps({}); await w.__updateProps({});
expect(w.props.p).toBe(4); expect(w.props.p).toBe(4);
}); });
}); });