mirror of
https://github.com/discourse/discourse.git
synced 2025-03-01 06:24:10 +08:00
DEV: ensures tree is present for traverseCustomWidgets (#13855)
We already had this check sometimes in code, it's just safer to have this responsibility baked in the function.
This commit is contained in:
parent
efe38efb0a
commit
d801e33e0b
@ -124,9 +124,7 @@ export default Component.extend({
|
|||||||
newTree._emberView = this;
|
newTree._emberView = this;
|
||||||
const patches = diff(this._tree || this._rootNode, newTree);
|
const patches = diff(this._tree || this._rootNode, newTree);
|
||||||
|
|
||||||
if (this._tree) {
|
traverseCustomWidgets(this._tree, (w) => w.willRerenderWidget());
|
||||||
traverseCustomWidgets(this._tree, (w) => w.willRerenderWidget());
|
|
||||||
}
|
|
||||||
|
|
||||||
this.beforePatch();
|
this.beforePatch();
|
||||||
this._rootNode = patch(this._rootNode, patches);
|
this._rootNode = patch(this._rootNode, patches);
|
||||||
|
@ -47,9 +47,7 @@ export default class WidgetGlue {
|
|||||||
});
|
});
|
||||||
const patches = diff(this._tree || this._rootNode, newTree);
|
const patches = diff(this._tree || this._rootNode, newTree);
|
||||||
|
|
||||||
if (this._tree) {
|
traverseCustomWidgets(this._tree, (w) => w.willRerenderWidget());
|
||||||
traverseCustomWidgets(this._tree, (w) => w.willRerenderWidget());
|
|
||||||
}
|
|
||||||
|
|
||||||
newTree._rerenderable = this;
|
newTree._rerenderable = this;
|
||||||
this._rootNode = patch(this._rootNode, patches);
|
this._rootNode = patch(this._rootNode, patches);
|
||||||
|
@ -38,6 +38,10 @@ export function decorateWidget(widgetName, cb) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function traverseCustomWidgets(tree, callback) {
|
export function traverseCustomWidgets(tree, callback) {
|
||||||
|
if (!tree) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (tree.__type === "CustomWidget") {
|
if (tree.__type === "CustomWidget") {
|
||||||
callback(tree);
|
callback(tree);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user