@rxdi/lit-html 0.7.141 → 0.7.142

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,6 +3,7 @@ import { CSSResult } from '../reactive-element/css-tag';
3
3
  export interface CustomAttributeRegistry {
4
4
  define(name: string, modifier: Function | Modifier): void;
5
5
  get(element: HTMLElement, attrName: string): any;
6
+ unsubscribe(): void;
6
7
  }
7
8
  export interface ModifierOptions {
8
9
  name: string;
@@ -32,6 +32,7 @@ const customElement = (tag, config = {}) => (Base) => {
32
32
  const disconnectedCallback = Base.prototype.disconnectedCallback || function () { };
33
33
  const update = Base.prototype.update || function () { };
34
34
  const firstUpdated = Base.prototype.firstUpdated || function () { };
35
+ let registry;
35
36
  if (!config.template) {
36
37
  config.template = Base.prototype.render || (() => (0, lit_html_1.html) ``);
37
38
  }
@@ -66,13 +67,13 @@ const customElement = (tag, config = {}) => (Base) => {
66
67
  disconnectedCallback() {
67
68
  OnDestroy.call(this);
68
69
  disconnectedCallback.call(this);
70
+ registry === null || registry === void 0 ? void 0 : registry.unsubscribe();
71
+ registry = null;
69
72
  }
70
73
  connectedCallback() {
74
+ var _a;
71
75
  connectedCallback.call(this);
72
76
  OnInit.call(this);
73
- }
74
- render() {
75
- var _a;
76
77
  if ((_a = config.modifiers) === null || _a === void 0 ? void 0 : _a.length) {
77
78
  for (const modifier of config.modifiers) {
78
79
  if (!modifier) {
@@ -88,15 +89,19 @@ const customElement = (tag, config = {}) => (Base) => {
88
89
  if (!(options === null || options === void 0 ? void 0 : options.name)) {
89
90
  throw new Error(`Missing attribute name for ${modifier.name} inside component "${config.selector}"`);
90
91
  }
91
- const registry = (isFunction(config.registry)
92
- ? config.registry.call(this)
93
- : options.registry);
92
+ if (!registry) {
93
+ registry = (isFunction(config.registry)
94
+ ? config.registry.call(this)
95
+ : options.registry);
96
+ }
94
97
  if (!registry) {
95
98
  throw new Error(`Missing attribute registry for attribute "${options.name}" and no default registry specified inside component "${config.selector}"`);
96
99
  }
97
100
  registry.define(options.name, modifier);
98
101
  }
99
102
  }
103
+ }
104
+ render() {
100
105
  return config.template.call(this);
101
106
  }
102
107
  update() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rxdi/lit-html",
3
- "version": "0.7.141",
3
+ "version": "0.7.142",
4
4
  "main": "./dist/index.js",
5
5
  "author": "Kristiyan Tachev",
6
6
  "license": "MIT",