Make `attach` optionally take a list of widget names to try

Make attach optionally take a list of widget names to try

diff --git a/app/assets/javascripts/discourse/widgets/widget.js.es6 b/app/assets/javascripts/discourse/widgets/widget.js.es6
index e1b1016..57290d7 100644
--- a/app/assets/javascripts/discourse/widgets/widget.js.es6
+++ b/app/assets/javascripts/discourse/widgets/widget.js.es6
@@ -270,18 +270,26 @@ export default class Widget {
     }
   }
 
-  attach(widgetName, attrs, opts) {
-    let WidgetClass = _registry[widgetName];
+  attach(widgetNames, attrs, opts) {
+    widgetNames = [].concat(widgetNames);
+    let WidgetClass = null;
+
+    for (let widgetName of widgetNames) {
+      WidgetClass = _registry[widgetName];
+      if (WidgetClass) {
+        break;
+      }
 
-    if (!WidgetClass) {
       if (!this.register) {
         // eslint-disable-next-line no-console
         console.error("couldn't find register");
         return;
       }
+
       WidgetClass = this.register.lookupFactory(`widget:${widgetName}`);
       if (WidgetClass && WidgetClass.class) {
         WidgetClass = WidgetClass.class;
+        break;
       }
     }
 
@@ -291,7 +299,7 @@ export default class Widget {
       result.dirtyKeys = this.dirtyKeys;
       return result;
     } else {
-      throw new Error(`Couldn't find ${widgetName} factory`);
+      throw new Error(`Couldn't find ${widgetNames} factory`);
     }
   }

GitHub sha: 01a7fd42