@rxdi/lit-html 0.7.143 → 0.7.146

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.
@@ -7,10 +7,10 @@ export interface CustomAttributeRegistry {
7
7
  }
8
8
  export interface ModifierOptions {
9
9
  selector: string;
10
- registry?: CustomAttributeRegistry;
10
+ registry?(this: HTMLElement): CustomAttributeRegistry;
11
11
  }
12
- export interface Modifier extends Function {
13
- options(): ModifierOptions;
12
+ export interface Modifier {
13
+ options: ModifierOptions;
14
14
  }
15
15
  export interface CustomElementConfig<T> {
16
16
  selector: string;
@@ -71,33 +71,30 @@ const customElement = (tag, config = {}) => (Base) => {
71
71
  registry = null;
72
72
  }
73
73
  connectedCallback() {
74
- var _a;
74
+ var _a, _b;
75
75
  connectedCallback.call(this);
76
76
  OnInit.call(this);
77
+ if (isFunction(config.registry)) {
78
+ registry = config.registry.call(this);
79
+ }
77
80
  if ((_a = config.modifiers) === null || _a === void 0 ? void 0 : _a.length) {
78
81
  for (const modifier of config.modifiers) {
79
82
  if (!modifier) {
80
83
  throw new Error(`Provided null value inside modifiers for component "${config.selector}"`);
81
84
  }
82
85
  if (!modifier.options) {
83
- throw new Error(`Missing options for attribute inside ${modifier.name}`);
84
- }
85
- if (typeof modifier.options !== 'function') {
86
- throw new Error(`Modifier options is not a function ${modifier.name} and component "${config.selector}"`);
86
+ throw new Error(`Missing options for attribute inside ${config.selector}`);
87
87
  }
88
- const options = modifier.options.call(this);
89
- if (!(options === null || options === void 0 ? void 0 : options.selector)) {
90
- throw new Error(`Missing attribute name for ${modifier.name} inside component "${config.selector}"`);
88
+ if (!((_b = modifier.options) === null || _b === void 0 ? void 0 : _b.selector)) {
89
+ throw new Error(`Missing attribute selector inside component "${config.selector}"`);
91
90
  }
92
- if (!registry) {
93
- registry = (isFunction(config.registry)
94
- ? config.registry.call(this)
95
- : options.registry);
91
+ if (!registry && typeof modifier.options.registry === 'function') {
92
+ registry = modifier.options.registry.call(this);
96
93
  }
97
94
  if (!registry) {
98
- throw new Error(`Missing attribute registry for attribute "${options.selector}" and no default registry specified inside component "${config.selector}"`);
95
+ throw new Error(`Missing attribute registry for attribute "${modifier.options.selector}" and no default registry specified inside component "${config.selector}"`);
99
96
  }
100
- registry.define(options.selector, modifier);
97
+ registry.define(modifier.options.selector, modifier);
101
98
  }
102
99
  }
103
100
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rxdi/lit-html",
3
- "version": "0.7.143",
3
+ "version": "0.7.146",
4
4
  "main": "./dist/index.js",
5
5
  "author": "Kristiyan Tachev",
6
6
  "license": "MIT",