A platform for community discussion. Free, open, simple.
PERF: Improve rendering performance of empty PluginOutlets (#23165)
David Taylor121cd886a4fa
diff --git a/app/assets/javascripts/discourse/app/components/plugin-outlet.hbs b/app/assets/javascripts/discourse/app/components/plugin-outlet.hbsindex 2639a58e88a..acf2e087f05 100644--- a/app/assets/javascripts/discourse/app/components/plugin-outlet.hbs+++ b/app/assets/javascripts/discourse/app/components/plugin-outlet.hbs@@ -22,7 +22,7 @@{{/if}}{{/each}}</this.wrapperComponent>-{{else}}+{{else if this.connectorsExist}}{{! The modern path: no wrapper element = no classic component }}{{#each this.connectors as |c|}}{{#if c.componentClass}}diff --git a/app/assets/javascripts/discourse/app/components/plugin-outlet.js b/app/assets/javascripts/discourse/app/components/plugin-outlet.jsindex 840c8b73f32..0fc1af240fb 100644--- a/app/assets/javascripts/discourse/app/components/plugin-outlet.js+++ b/app/assets/javascripts/discourse/app/components/plugin-outlet.js@@ -3,6 +3,7 @@ import ClassicComponent from "@ember/component";import {buildArgsWithDeprecations,+ connectorsExist,renderedConnectorsFor,} from "discourse/lib/plugin-connectors";import { helperContext } from "discourse-common/lib/helpers";@@ -86,6 +87,10 @@ export default class PluginOutletComponent extends GlimmerComponentWithDeprecate);}+ get connectorsExist() {+ return connectorsExist(this.args.name);+ }+// Traditionally, pluginOutlets had an argument named 'args'. However, that name is reserved// in recent versions of ember so we need to migrate to outletArgs@cacheddiff --git a/app/assets/javascripts/discourse/app/lib/plugin-connectors.js b/app/assets/javascripts/discourse/app/lib/plugin-connectors.jsindex 2a7e1411f8a..8960ab848b7 100644--- a/app/assets/javascripts/discourse/app/lib/plugin-connectors.js+++ b/app/assets/javascripts/discourse/app/lib/plugin-connectors.js@@ -165,6 +165,13 @@ function buildConnectorCache() {}}+export function connectorsExist(outletName) {+ if (!_connectorCache) {+ buildConnectorCache();+ }+ return Boolean(_connectorCache[outletName]);+}+export function connectorsFor(outletName) {if (!_connectorCache) {buildConnectorCache();