mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
ref: update owl.js, use componentdidupdate
This commit is contained in:
+19
-5
@@ -918,6 +918,15 @@
|
|||||||
* @see willUnmount
|
* @see willUnmount
|
||||||
*/
|
*/
|
||||||
mounted() { }
|
mounted() { }
|
||||||
|
/**
|
||||||
|
* This hook is called whenever a component did actually update its props,
|
||||||
|
* state or env.
|
||||||
|
*
|
||||||
|
* This method is not called on the initial render. It is useful to interact
|
||||||
|
* with the DOM (for example, through an external library) whenever the
|
||||||
|
* component was updated.
|
||||||
|
*/
|
||||||
|
componentDidUpdate() { }
|
||||||
/**
|
/**
|
||||||
* willUnmount is a hook that is called each time a component is detached from
|
* willUnmount is a hook that is called each time a component is detached from
|
||||||
* the DOM. This is a good place to remove some listeners, for example.
|
* the DOM. This is a good place to remove some listeners, for example.
|
||||||
@@ -1040,8 +1049,9 @@
|
|||||||
}
|
}
|
||||||
Object.assign(this.env, nextEnv);
|
Object.assign(this.env, nextEnv);
|
||||||
if (this.__widget__.isMounted) {
|
if (this.__widget__.isMounted) {
|
||||||
return this.render(true);
|
await this.render(true);
|
||||||
}
|
}
|
||||||
|
this.componentDidUpdate();
|
||||||
}
|
}
|
||||||
async updateProps(nextProps, forceUpdate = false) {
|
async updateProps(nextProps, forceUpdate = false) {
|
||||||
if (nextProps === this.__widget__.renderProps && !forceUpdate) {
|
if (nextProps === this.__widget__.renderProps && !forceUpdate) {
|
||||||
@@ -1066,15 +1076,17 @@
|
|||||||
}
|
}
|
||||||
Object.assign(this.state, nextState);
|
Object.assign(this.state, nextState);
|
||||||
if (this.__widget__.isStarted) {
|
if (this.__widget__.isStarted) {
|
||||||
return this.render();
|
await this.render();
|
||||||
}
|
}
|
||||||
|
this.componentDidUpdate();
|
||||||
}
|
}
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
// Private
|
// Private
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
async _updateProps(nextProps) {
|
async _updateProps(nextProps) {
|
||||||
this.props = nextProps;
|
this.props = nextProps;
|
||||||
return this.render();
|
await this.render();
|
||||||
|
this.componentDidUpdate();
|
||||||
}
|
}
|
||||||
_patch(vnode) {
|
_patch(vnode) {
|
||||||
this.__widget__.renderPromise = null;
|
this.__widget__.renderPromise = null;
|
||||||
@@ -2043,9 +2055,11 @@
|
|||||||
this.updateProps(nextProps, false);
|
this.updateProps(nextProps, false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
super.mounted();
|
||||||
}
|
}
|
||||||
willUnmount() {
|
willUnmount() {
|
||||||
this.env.store.off("update", this);
|
this.env.store.off("update", this);
|
||||||
|
super.willUnmount();
|
||||||
}
|
}
|
||||||
updateProps(nextProps, forceUpdate) {
|
updateProps(nextProps, forceUpdate) {
|
||||||
nextProps = Object.assign(nextProps, this.__widget__.currentStoreProps);
|
nextProps = Object.assign(nextProps, this.__widget__.currentStoreProps);
|
||||||
@@ -2120,7 +2134,7 @@
|
|||||||
exports.extras = extras;
|
exports.extras = extras;
|
||||||
|
|
||||||
exports._version = '0.4.0';
|
exports._version = '0.4.0';
|
||||||
exports._date = '2019-03-29T15:41:21.984Z';
|
exports._date = '2019-04-01T14:01:57.709Z';
|
||||||
exports._hash = 'd6e61c2';
|
exports._hash = '990a08d';
|
||||||
|
|
||||||
}(this.owl = this.owl || {}));
|
}(this.owl = this.owl || {}));
|
||||||
|
|||||||
+1
-3
@@ -59,13 +59,11 @@ class TabbedEditor extends Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
updateProps() {
|
componentDidUpdate() {
|
||||||
const result = super.updateProps(...arguments);
|
|
||||||
if (this.editor) {
|
if (this.editor) {
|
||||||
window.dispatchEvent(new Event("resize"));
|
window.dispatchEvent(new Event("resize"));
|
||||||
this.editor.setValue(this.props[this.state.currentTab], -1);
|
this.editor.setValue(this.props[this.state.currentTab], -1);
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
willUnmount() {
|
willUnmount() {
|
||||||
|
|||||||
Reference in New Issue
Block a user