DEV: ensures tree is present for traverseCustomWidgets ()

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:
Joffrey JAFFEUX 2021-07-27 11:37:40 +02:00 committed by GitHub
parent efe38efb0a
commit d801e33e0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 6 deletions
app/assets/javascripts/discourse/app

@ -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);
} }