summaryrefslogtreecommitdiffstats
path: root/browser/components/aboutlogins/content/utils/controllers.mjs
diff options
context:
space:
mode:
Diffstat (limited to 'browser/components/aboutlogins/content/utils/controllers.mjs')
-rw-r--r--browser/components/aboutlogins/content/utils/controllers.mjs18
1 files changed, 18 insertions, 0 deletions
diff --git a/browser/components/aboutlogins/content/utils/controllers.mjs b/browser/components/aboutlogins/content/utils/controllers.mjs
new file mode 100644
index 0000000000..13c46dfcaf
--- /dev/null
+++ b/browser/components/aboutlogins/content/utils/controllers.mjs
@@ -0,0 +1,18 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+// Simple controller wrapper that binds a controller and runs cleanup function
+// https://lit.dev/docs/composition/controllers/
+export const withSimpleController = (host, functionToBind, ...args) =>
+ class {
+ constructor() {
+ host.addController(this);
+ }
+ hostConnected() {
+ this.cleanup = functionToBind?.(host, ...args);
+ }
+ hostDisconnected() {
+ this.cleanup?.();
+ }
+ };