@rxdi/lit-html 0.7.157 → 0.7.159

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.
Files changed (95) hide show
  1. package/dist/async.d.ts +3 -3
  2. package/dist/async.js +4 -4
  3. package/dist/decorators/component.decorator.d.ts +1 -2
  4. package/dist/decorators/component.decorator.js +3 -3
  5. package/dist/index.d.ts +28 -17
  6. package/dist/index.js +28 -17
  7. package/package.json +4 -2
  8. package/dist/lit-element/decorators.d.ts +0 -14
  9. package/dist/lit-element/decorators.js +0 -32
  10. package/dist/lit-element/experimental-hydrate-support.d.ts +0 -6
  11. package/dist/lit-element/experimental-hydrate-support.js +0 -65
  12. package/dist/lit-element/index.d.ts +0 -7
  13. package/dist/lit-element/index.js +0 -25
  14. package/dist/lit-element/lit-element.d.ts +0 -157
  15. package/dist/lit-element/lit-element.js +0 -258
  16. package/dist/lit-element/polyfill-support.d.ts +0 -24
  17. package/dist/lit-element/polyfill-support.js +0 -58
  18. package/dist/lit-element/private-ssr-support.d.ts +0 -21
  19. package/dist/lit-element/private-ssr-support.js +0 -25
  20. package/dist/lit-html/async-directive.d.ts +0 -170
  21. package/dist/lit-html/async-directive.js +0 -250
  22. package/dist/lit-html/directive-helpers.d.ts +0 -105
  23. package/dist/lit-html/directive-helpers.js +0 -192
  24. package/dist/lit-html/directive.d.ts +0 -65
  25. package/dist/lit-html/directive.js +0 -52
  26. package/dist/lit-html/directives/async-append.d.ts +0 -38
  27. package/dist/lit-html/directives/async-append.js +0 -55
  28. package/dist/lit-html/directives/async-replace.d.ts +0 -39
  29. package/dist/lit-html/directives/async-replace.js +0 -112
  30. package/dist/lit-html/directives/cache.d.ts +0 -34
  31. package/dist/lit-html/directives/cache.js +0 -80
  32. package/dist/lit-html/directives/class-map.d.ts +0 -44
  33. package/dist/lit-html/directives/class-map.js +0 -92
  34. package/dist/lit-html/directives/guard.d.ts +0 -59
  35. package/dist/lit-html/directives/guard.js +0 -82
  36. package/dist/lit-html/directives/if-defined.d.ts +0 -13
  37. package/dist/lit-html/directives/if-defined.js +0 -17
  38. package/dist/lit-html/directives/live.d.ts +0 -42
  39. package/dist/lit-html/directives/live.js +0 -79
  40. package/dist/lit-html/directives/private-async-helpers.d.ts +0 -57
  41. package/dist/lit-html/directives/private-async-helpers.js +0 -117
  42. package/dist/lit-html/directives/ref.d.ts +0 -65
  43. package/dist/lit-html/directives/ref.js +0 -113
  44. package/dist/lit-html/directives/repeat.d.ts +0 -63
  45. package/dist/lit-html/directives/repeat.js +0 -416
  46. package/dist/lit-html/directives/style-map.d.ts +0 -46
  47. package/dist/lit-html/directives/style-map.js +0 -102
  48. package/dist/lit-html/directives/template-content.d.ts +0 -25
  49. package/dist/lit-html/directives/template-content.js +0 -33
  50. package/dist/lit-html/directives/unsafe-html.d.ts +0 -26
  51. package/dist/lit-html/directives/unsafe-html.js +0 -64
  52. package/dist/lit-html/directives/unsafe-svg.d.ts +0 -26
  53. package/dist/lit-html/directives/unsafe-svg.js +0 -26
  54. package/dist/lit-html/directives/until.d.ts +0 -43
  55. package/dist/lit-html/directives/until.js +0 -137
  56. package/dist/lit-html/experimental-hydrate.d.ts +0 -50
  57. package/dist/lit-html/experimental-hydrate.js +0 -322
  58. package/dist/lit-html/lit-html.d.ts +0 -335
  59. package/dist/lit-html/lit-html.js +0 -1259
  60. package/dist/lit-html/polyfill-support.d.ts +0 -67
  61. package/dist/lit-html/polyfill-support.js +0 -185
  62. package/dist/lit-html/private-ssr-support.d.ts +0 -52
  63. package/dist/lit-html/private-ssr-support.js +0 -54
  64. package/dist/lit-html/static.d.ts +0 -58
  65. package/dist/lit-html/static.js +0 -114
  66. package/dist/reactive-element/css-tag.d.ts +0 -64
  67. package/dist/reactive-element/css-tag.js +0 -125
  68. package/dist/reactive-element/decorators/base.d.ts +0 -47
  69. package/dist/reactive-element/decorators/base.js +0 -70
  70. package/dist/reactive-element/decorators/custom-element.d.ts +0 -26
  71. package/dist/reactive-element/decorators/custom-element.js +0 -47
  72. package/dist/reactive-element/decorators/event-options.d.ts +0 -37
  73. package/dist/reactive-element/decorators/event-options.js +0 -47
  74. package/dist/reactive-element/decorators/index.d.ts +0 -14
  75. package/dist/reactive-element/decorators/index.js +0 -32
  76. package/dist/reactive-element/decorators/property.d.ts +0 -40
  77. package/dist/reactive-element/decorators/property.js +0 -92
  78. package/dist/reactive-element/decorators/query-all.d.ts +0 -31
  79. package/dist/reactive-element/decorators/query-all.js +0 -46
  80. package/dist/reactive-element/decorators/query-assigned-nodes.d.ts +0 -33
  81. package/dist/reactive-element/decorators/query-assigned-nodes.js +0 -55
  82. package/dist/reactive-element/decorators/query-async.d.ts +0 -39
  83. package/dist/reactive-element/decorators/query-async.js +0 -71
  84. package/dist/reactive-element/decorators/query.d.ts +0 -32
  85. package/dist/reactive-element/decorators/query.js +0 -60
  86. package/dist/reactive-element/decorators/state.d.ts +0 -24
  87. package/dist/reactive-element/decorators/state.js +0 -29
  88. package/dist/reactive-element/index.d.ts +0 -5
  89. package/dist/reactive-element/index.js +0 -17
  90. package/dist/reactive-element/polyfill-support.d.ts +0 -40
  91. package/dist/reactive-element/polyfill-support.js +0 -89
  92. package/dist/reactive-element/reactive-controller.d.ts +0 -76
  93. package/dist/reactive-element/reactive-controller.js +0 -7
  94. package/dist/reactive-element/reactive-element.d.ts +0 -653
  95. package/dist/reactive-element/reactive-element.js +0 -979
@@ -1,258 +0,0 @@
1
- "use strict";
2
- /**
3
- * @license
4
- * Copyright 2017 Google LLC
5
- * SPDX-License-Identifier: BSD-3-Clause
6
- */
7
- var _a, _b, _c, _d;
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports._$LE = exports.LitElement = exports.UpdatingElement = void 0;
10
- /**
11
- * The main LitElement module, which defines the [[`LitElement`]] base class and
12
- * related APIs.
13
- *
14
- * LitElement components can define a template and a set of observed
15
- * properties. Changing an observed property triggers a re-render of the
16
- * element.
17
- *
18
- * Import [[`LitElement`]] and [[`html`]] from this module to create a
19
- * component:
20
- *
21
- * ```js
22
- * import {LitElement, html} from 'lit-element';
23
- *
24
- * class MyElement extends LitElement {
25
- *
26
- * // Declare observed properties
27
- * static get properties() {
28
- * return {
29
- * adjective: {}
30
- * }
31
- * }
32
- *
33
- * constructor() {
34
- * this.adjective = 'awesome';
35
- * }
36
- *
37
- * // Define the element's template
38
- * render() {
39
- * return html`<p>your ${adjective} template here</p>`;
40
- * }
41
- * }
42
- *
43
- * customElements.define('my-element', MyElement);
44
- * ```
45
- *
46
- * `LitElement` extends [[`ReactiveElement`]] and adds lit-html templating.
47
- * The `ReactiveElement` class is provided for users that want to build
48
- * their own custom element base classes that don't use lit-html.
49
- *
50
- * @packageDocumentation
51
- */
52
- const reactive_element_1 = require("../reactive-element");
53
- const lit_html_1 = require("../lit-html/lit-html");
54
- // For backwards compatibility export ReactiveElement as UpdatingElement. Note,
55
- // IE transpilation requires exporting like this.
56
- exports.UpdatingElement = reactive_element_1.ReactiveElement;
57
- const DEV_MODE = true;
58
- let issueWarning;
59
- if (DEV_MODE) {
60
- // Ensure warnings are issued only 1x, even if multiple versions of Lit
61
- // are loaded.
62
- const issuedWarnings = ((_a = globalThis.litIssuedWarnings) !== null && _a !== void 0 ? _a : (globalThis.litIssuedWarnings = new Set()));
63
- // Issue a warning, if we haven't already.
64
- issueWarning = (code, warning) => {
65
- warning += ` See https://lit.dev/msg/${code} for more information.`;
66
- if (!issuedWarnings.has(warning)) {
67
- console.warn(warning);
68
- issuedWarnings.add(warning);
69
- }
70
- };
71
- }
72
- /**
73
- * Base element class that manages element properties and attributes, and
74
- * renders a lit-html template.
75
- *
76
- * To define a component, subclass `LitElement` and implement a
77
- * `render` method to provide the component's template. Define properties
78
- * using the [[`properties`]] property or the [[`property`]] decorator.
79
- */
80
- class LitElement extends reactive_element_1.ReactiveElement {
81
- constructor() {
82
- super(...arguments);
83
- /**
84
- * @category rendering
85
- */
86
- this.renderOptions = { host: this };
87
- this.__childPart = undefined;
88
- }
89
- /**
90
- * @category rendering
91
- */
92
- createRenderRoot() {
93
- var _a;
94
- var _b;
95
- const renderRoot = super.createRenderRoot();
96
- // When adoptedStyleSheets are shimmed, they are inserted into the
97
- // shadowRoot by createRenderRoot. Adjust the renderBefore node so that
98
- // any styles in Lit content render before adoptedStyleSheets. This is
99
- // important so that adoptedStyleSheets have precedence over styles in
100
- // the shadowRoot.
101
- (_a = (_b = this.renderOptions).renderBefore) !== null && _a !== void 0 ? _a : (_b.renderBefore = renderRoot.firstChild);
102
- return renderRoot;
103
- }
104
- /**
105
- * Updates the element. This method reflects property values to attributes
106
- * and calls `render` to render DOM via lit-html. Setting properties inside
107
- * this method will *not* trigger another update.
108
- * @param changedProperties Map of changed properties with old values
109
- * @category updates
110
- */
111
- update(changedProperties) {
112
- // Setting properties in `render` should not trigger an update. Since
113
- // updates are allowed after super.update, it's important to call `render`
114
- // before that.
115
- const value = this.render();
116
- if (!this.hasUpdated) {
117
- this.renderOptions.isConnected = this.isConnected;
118
- }
119
- super.update(changedProperties);
120
- this.__childPart = (0, lit_html_1.render)(value, this.renderRoot, this.renderOptions);
121
- }
122
- /**
123
- * Invoked when the component is added to the document's DOM.
124
- *
125
- * In `connectedCallback()` you should setup tasks that should only occur when
126
- * the element is connected to the document. The most common of these is
127
- * adding event listeners to nodes external to the element, like a keydown
128
- * event handler added to the window.
129
- *
130
- * ```ts
131
- * connectedCallback() {
132
- * super.connectedCallback();
133
- * addEventListener('keydown', this._handleKeydown);
134
- * }
135
- * ```
136
- *
137
- * Typically, anything done in `connectedCallback()` should be undone when the
138
- * element is disconnected, in `disconnectedCallback()`.
139
- *
140
- * @category lifecycle
141
- */
142
- connectedCallback() {
143
- var _a;
144
- super.connectedCallback();
145
- (_a = this.__childPart) === null || _a === void 0 ? void 0 : _a.setConnected(true);
146
- }
147
- /**
148
- * Invoked when the component is removed from the document's DOM.
149
- *
150
- * This callback is the main signal to the element that it may no longer be
151
- * used. `disconnectedCallback()` should ensure that nothing is holding a
152
- * reference to the element (such as event listeners added to nodes external
153
- * to the element), so that it is free to be garbage collected.
154
- *
155
- * ```ts
156
- * disconnectedCallback() {
157
- * super.disconnectedCallback();
158
- * window.removeEventListener('keydown', this._handleKeydown);
159
- * }
160
- * ```
161
- *
162
- * An element may be re-connected after being disconnected.
163
- *
164
- * @category lifecycle
165
- */
166
- disconnectedCallback() {
167
- var _a;
168
- super.disconnectedCallback();
169
- (_a = this.__childPart) === null || _a === void 0 ? void 0 : _a.setConnected(false);
170
- }
171
- /**
172
- * Invoked on each update to perform rendering tasks. This method may return
173
- * any value renderable by lit-html's `ChildPart` - typically a
174
- * `TemplateResult`. Setting properties inside this method will *not* trigger
175
- * the element to update.
176
- * @category rendering
177
- */
178
- render() {
179
- return lit_html_1.noChange;
180
- }
181
- }
182
- exports.LitElement = LitElement;
183
- /**
184
- * Ensure this class is marked as `finalized` as an optimization ensuring
185
- * it will not needlessly try to `finalize`.
186
- *
187
- * Note this property name is a string to prevent breaking Closure JS Compiler
188
- * optimizations. See @lit/reactive-element for more information.
189
- */
190
- LitElement['finalized'] = true;
191
- // This property needs to remain unminified.
192
- LitElement['_$litElement$'] = true;
193
- // Install hydration if available
194
- (_b = globalThis.litElementHydrateSupport) === null || _b === void 0 ? void 0 : _b.call(globalThis, { LitElement });
195
- // Apply polyfills if available
196
- (_c = globalThis[`litElementPolyfillSupport${DEV_MODE ? `DevMode` : ``}`]) === null || _c === void 0 ? void 0 : _c.call(globalThis, {
197
- LitElement,
198
- });
199
- // DEV mode warnings
200
- if (DEV_MODE) {
201
- /* eslint-disable @typescript-eslint/no-explicit-any */
202
- // Note, for compatibility with closure compilation, this access
203
- // needs to be as a string property index.
204
- LitElement['finalize'] = function () {
205
- const finalized = reactive_element_1.ReactiveElement.finalize.call(this);
206
- if (!finalized) {
207
- return false;
208
- }
209
- const warnRemovedOrRenamed = (obj, name, renamed = false) => {
210
- if (obj.hasOwnProperty(name)) {
211
- const ctorName = (typeof obj === 'function' ? obj : obj.constructor)
212
- .name;
213
- issueWarning(renamed ? 'renamed-api' : 'removed-api', `\`${name}\` is implemented on class ${ctorName}. It ` +
214
- `has been ${renamed ? 'renamed' : 'removed'} ` +
215
- `in this version of LitElement.`);
216
- }
217
- };
218
- warnRemovedOrRenamed(this, 'render');
219
- warnRemovedOrRenamed(this, 'getStyles', true);
220
- warnRemovedOrRenamed(this.prototype, 'adoptStyles');
221
- return true;
222
- };
223
- /* eslint-enable @typescript-eslint/no-explicit-any */
224
- }
225
- /**
226
- * END USERS SHOULD NOT RELY ON THIS OBJECT.
227
- *
228
- * Private exports for use by other Lit packages, not intended for use by
229
- * external users.
230
- *
231
- * We currently do not make a mangled rollup build of the lit-ssr code. In order
232
- * to keep a number of (otherwise private) top-level exports mangled in the
233
- * client side code, we export a _$LE object containing those members (or
234
- * helper methods for accessing private fields of those members), and then
235
- * re-export them for use in lit-ssr. This keeps lit-ssr agnostic to whether the
236
- * client-side code is being used in `dev` mode or `prod` mode.
237
- *
238
- * This has a unique name, to disambiguate it from private exports in
239
- * lit-html, since this module re-exports all of lit-html.
240
- *
241
- * @private
242
- */
243
- exports._$LE = {
244
- _$attributeToProperty: (el, name, value) => {
245
- // eslint-disable-next-line
246
- el._$attributeToProperty(name, value);
247
- },
248
- // eslint-disable-next-line
249
- _$changedProperties: (el) => el._$changedProperties,
250
- };
251
- // IMPORTANT: do not change the property name or the assignment expression.
252
- // This line will be used in regexes to search for LitElement usage.
253
- // TODO(justinfagnani): inject version number at build time
254
- ((_d = globalThis.litElementVersions) !== null && _d !== void 0 ? _d : (globalThis.litElementVersions = [])).push('3.0.0');
255
- if (DEV_MODE && globalThis.litElementVersions.length > 1) {
256
- issueWarning('multiple-versions', `Multiple versions of Lit loaded. Loading multiple versions ` +
257
- `is not recommended.`);
258
- }
@@ -1,24 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2017 Google LLC
4
- * SPDX-License-Identifier: BSD-3-Clause
5
- */
6
- /**
7
- * LitElement patch to support browsers without native web components.
8
- *
9
- * This module should be used in addition to loading the web components
10
- * polyfills via @webcomponents/webcomponentjs. When using those polyfills
11
- * support for polyfilled Shadow DOM is automatic via the ShadyDOM polyfill, but
12
- * support for Shadow DOM like css scoping is opt-in. This module uses ShadyCSS
13
- * to scope styles defined via the `static styles` property and styles included
14
- * in the render method. There are some limitations to be aware of:
15
- * * only styles that are included in the first render of a component are scoped.
16
- * * In addition, support for the deprecated `@apply` feature of ShadyCSS is
17
- * only provided for styles included in the template and not styles provided
18
- * via the static styles property.
19
- * * Lit parts cannot be used in styles included in the template.
20
- *
21
- * @packageDocumentation
22
- */
23
- import '../reactive-element/polyfill-support';
24
- import '../lit-html/polyfill-support';
@@ -1,58 +0,0 @@
1
- "use strict";
2
- /**
3
- * @license
4
- * Copyright 2017 Google LLC
5
- * SPDX-License-Identifier: BSD-3-Clause
6
- */
7
- var _a;
8
- var _b;
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- /**
11
- * LitElement patch to support browsers without native web components.
12
- *
13
- * This module should be used in addition to loading the web components
14
- * polyfills via @webcomponents/webcomponentjs. When using those polyfills
15
- * support for polyfilled Shadow DOM is automatic via the ShadyDOM polyfill, but
16
- * support for Shadow DOM like css scoping is opt-in. This module uses ShadyCSS
17
- * to scope styles defined via the `static styles` property and styles included
18
- * in the render method. There are some limitations to be aware of:
19
- * * only styles that are included in the first render of a component are scoped.
20
- * * In addition, support for the deprecated `@apply` feature of ShadyCSS is
21
- * only provided for styles included in the template and not styles provided
22
- * via the static styles property.
23
- * * Lit parts cannot be used in styles included in the template.
24
- *
25
- * @packageDocumentation
26
- */
27
- require("../reactive-element/polyfill-support");
28
- require("../lit-html/polyfill-support");
29
- // Note, explicitly use `var` here so that this can be re-defined when
30
- // bundled.
31
- // eslint-disable-next-line no-var
32
- var DEV_MODE = true;
33
- (_a = globalThis[_b = `litElementPolyfillSupport${DEV_MODE ? `DevMode` : ``}`]) !== null && _a !== void 0 ? _a : (globalThis[_b] = ({ LitElement, }) => {
34
- // polyfill-support is only needed if ShadyCSS or the ApplyShim is in use
35
- // We test at the point of patching, which makes it safe to load
36
- // webcomponentsjs and polyfill-support in either order
37
- if (window.ShadyCSS === undefined ||
38
- (window.ShadyCSS.nativeShadow && !window.ShadyCSS.ApplyShim)) {
39
- return;
40
- }
41
- // console.log(
42
- // '%c Making LitElement compatible with ShadyDOM/CSS.',
43
- // 'color: lightgreen; font-style: italic'
44
- // );
45
- LitElement._$handlesPrepareStyles = true;
46
- /**
47
- * Patch to apply adoptedStyleSheets via ShadyCSS
48
- */
49
- const litElementProto = LitElement.prototype;
50
- const createRenderRoot = litElementProto.createRenderRoot;
51
- litElementProto.createRenderRoot = function () {
52
- // Pass the scope to render options so that it gets to lit-html for proper
53
- // scoping via ShadyCSS. This is needed under Shady and also Shadow DOM,
54
- // due to @apply.
55
- this.renderOptions.scope = this.localName;
56
- return createRenderRoot.call(this);
57
- };
58
- });
@@ -1,21 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2017 Google LLC
4
- * SPDX-License-Identifier: BSD-3-Clause
5
- */
6
- /**
7
- * END USERS SHOULD NOT RELY ON THIS OBJECT.
8
- *
9
- * We currently do not make a mangled rollup build of the lit-ssr code. In order
10
- * to keep a number of (otherwise private) top-level exports mangled in the
11
- * client side code, we export a _$LE object containing those members (or
12
- * helper methods for accessing private fields of those members), and then
13
- * re-export them for use in lit-ssr. This keeps lit-ssr agnostic to whether the
14
- * client-side code is being used in `dev` mode or `prod` mode.
15
- *
16
- * @private
17
- */
18
- export declare const _$LE: {
19
- attributeToProperty: (el: import("./lit-element").LitElement, name: string, value: string) => void;
20
- changedProperties: (el: import("./lit-element").LitElement) => any;
21
- };
@@ -1,25 +0,0 @@
1
- "use strict";
2
- /**
3
- * @license
4
- * Copyright 2017 Google LLC
5
- * SPDX-License-Identifier: BSD-3-Clause
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports._$LE = void 0;
9
- const lit_element_1 = require("./lit-element");
10
- /**
11
- * END USERS SHOULD NOT RELY ON THIS OBJECT.
12
- *
13
- * We currently do not make a mangled rollup build of the lit-ssr code. In order
14
- * to keep a number of (otherwise private) top-level exports mangled in the
15
- * client side code, we export a _$LE object containing those members (or
16
- * helper methods for accessing private fields of those members), and then
17
- * re-export them for use in lit-ssr. This keeps lit-ssr agnostic to whether the
18
- * client-side code is being used in `dev` mode or `prod` mode.
19
- *
20
- * @private
21
- */
22
- exports._$LE = {
23
- attributeToProperty: lit_element_1._$LE._$attributeToProperty,
24
- changedProperties: lit_element_1._$LE._$changedProperties,
25
- };
@@ -1,170 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2017 Google LLC
4
- * SPDX-License-Identifier: BSD-3-Clause
5
- */
6
- /**
7
- * Overview:
8
- *
9
- * This module is designed to add support for an async `setValue` API and
10
- * `disconnected` callback to directives with the least impact on the core
11
- * runtime or payload when that feature is not used.
12
- *
13
- * The strategy is to introduce a `AsyncDirective` subclass of
14
- * `Directive` that climbs the "parent" tree in its constructor to note which
15
- * branches of lit-html's "logical tree" of data structures contain such
16
- * directives and thus need to be crawled when a subtree is being cleared (or
17
- * manually disconnected) in order to run the `disconnected` callback.
18
- *
19
- * The "nodes" of the logical tree include Parts, TemplateInstances (for when a
20
- * TemplateResult is committed to a value of a ChildPart), and Directives; these
21
- * all implement a common interface called `DisconnectableChild`. Each has a
22
- * `_$parent` reference which is set during construction in the core code, and a
23
- * `_$disconnectableChildren` field which is initially undefined.
24
- *
25
- * The sparse tree created by means of the `AsyncDirective` constructor
26
- * crawling up the `_$parent` tree and placing a `_$disconnectableChildren` Set
27
- * on each parent that includes each child that contains a
28
- * `AsyncDirective` directly or transitively via its children. In order to
29
- * notify connection state changes and disconnect (or reconnect) a tree, the
30
- * `_$notifyConnectionChanged` API is patched onto ChildParts as a directive
31
- * climbs the parent tree, which is called by the core when clearing a part if
32
- * it exists. When called, that method iterates over the sparse tree of
33
- * Set<DisconnectableChildren> built up by AsyncDirectives, and calls
34
- * `_$notifyDirectiveConnectionChanged` on any directives that are encountered
35
- * in that tree, running the required callbacks.
36
- *
37
- * A given "logical tree" of lit-html data-structures might look like this:
38
- *
39
- * ChildPart(N1) _$dC=[D2,T3]
40
- * ._directive
41
- * AsyncDirective(D2)
42
- * ._value // user value was TemplateResult
43
- * TemplateInstance(T3) _$dC=[A4,A6,N10,N12]
44
- * ._parts[]
45
- * AttributePart(A4) _$dC=[D5]
46
- * ._directives[]
47
- * AsyncDirective(D5)
48
- * AttributePart(A6) _$dC=[D7,D8]
49
- * ._directives[]
50
- * AsyncDirective(D7)
51
- * Directive(D8) _$dC=[D9]
52
- * ._directive
53
- * AsyncDirective(D9)
54
- * ChildPart(N10) _$dC=[D11]
55
- * ._directive
56
- * AsyncDirective(D11)
57
- * ._value
58
- * string
59
- * ChildPart(N12) _$dC=[D13,N14,N16]
60
- * ._directive
61
- * AsyncDirective(D13)
62
- * ._value // user value was iterable
63
- * Array<ChildPart>
64
- * ChildPart(N14) _$dC=[D15]
65
- * ._value
66
- * string
67
- * ChildPart(N16) _$dC=[D17,T18]
68
- * ._directive
69
- * AsyncDirective(D17)
70
- * ._value // user value was TemplateResult
71
- * TemplateInstance(T18) _$dC=[A19,A21,N25]
72
- * ._parts[]
73
- * AttributePart(A19) _$dC=[D20]
74
- * ._directives[]
75
- * AsyncDirective(D20)
76
- * AttributePart(A21) _$dC=[22,23]
77
- * ._directives[]
78
- * AsyncDirective(D22)
79
- * Directive(D23) _$dC=[D24]
80
- * ._directive
81
- * AsyncDirective(D24)
82
- * ChildPart(N25) _$dC=[D26]
83
- * ._directive
84
- * AsyncDirective(D26)
85
- * ._value
86
- * string
87
- *
88
- * Example 1: The directive in ChildPart(N12) updates and returns `nothing`. The
89
- * ChildPart will _clear() itself, and so we need to disconnect the "value" of
90
- * the ChildPart (but not its directive). In this case, when `_clear()` calls
91
- * `_$notifyConnectionChanged()`, we don't iterate all of the
92
- * _$disconnectableChildren, rather we do a value-specific disconnection: i.e.
93
- * since the _value was an Array<ChildPart> (because an iterable had been
94
- * committed), we iterate the array of ChildParts (N14, N16) and run
95
- * `setConnected` on them (which does recurse down the full tree of
96
- * `_$disconnectableChildren` below it, and also removes N14 and N16 from N12's
97
- * `_$disconnectableChildren`). Once the values have been disconnected, we then
98
- * check whether the ChildPart(N12)'s list of `_$disconnectableChildren` is empty
99
- * (and would remove it from its parent TemplateInstance(T3) if so), but since
100
- * it would still contain its directive D13, it stays in the disconnectable
101
- * tree.
102
- *
103
- * Example 2: In the course of Example 1, `setConnected` will reach
104
- * ChildPart(N16); in this case the entire part is being disconnected, so we
105
- * simply iterate all of N16's `_$disconnectableChildren` (D17,T18) and
106
- * recursively run `setConnected` on them. Note that we only remove children
107
- * from `_$disconnectableChildren` for the top-level values being disconnected
108
- * on a clear; doing this bookkeeping lower in the tree is wasteful since it's
109
- * all being thrown away.
110
- *
111
- * Example 3: If the LitElement containing the entire tree above becomes
112
- * disconnected, it will run `childPart.setConnected()` (which calls
113
- * `childPart._$notifyConnectionChanged()` if it exists); in this case, we
114
- * recursively run `setConnected()` over the entire tree, without removing any
115
- * children from `_$disconnectableChildren`, since this tree is required to
116
- * re-connect the tree, which does the same operation, simply passing
117
- * `isConnectd: true` down the tree, signaling which callback to run.
118
- */
119
- import { Disconnectable, Part } from './lit-html';
120
- import { Directive } from './directive';
121
- export { directive } from './directive';
122
- /**
123
- * An abstract `Directive` base class whose `disconnected` method will be
124
- * called when the part containing the directive is cleared as a result of
125
- * re-rendering, or when the user calls `part.setConnected(false)` on
126
- * a part that was previously rendered containing the directive (as happens
127
- * when e.g. a LitElement disconnects from the DOM).
128
- *
129
- * If `part.setConnected(true)` is subsequently called on a
130
- * containing part, the directive's `reconnected` method will be called prior
131
- * to its next `update`/`render` callbacks. When implementing `disconnected`,
132
- * `reconnected` should also be implemented to be compatible with reconnection.
133
- *
134
- * Note that updates may occur while the directive is disconnected. As such,
135
- * directives should generally check the `this.isConnected` flag during
136
- * render/update to determine whether it is safe to subscribe to resources
137
- * that may prevent garbage collection.
138
- */
139
- export declare abstract class AsyncDirective extends Directive {
140
- /**
141
- * The connection state for this Directive.
142
- */
143
- isConnected: boolean;
144
- /**
145
- * Initialize the part with internal fields
146
- * @param part
147
- * @param parent
148
- * @param attributeIndex
149
- */
150
- _$initialize(part: Part, parent: Disconnectable, attributeIndex: number | undefined): void;
151
- /**
152
- * Sets the value of the directive's Part outside the normal `update`/`render`
153
- * lifecycle of a directive.
154
- *
155
- * This method should not be called synchronously from a directive's `update`
156
- * or `render`.
157
- *
158
- * @param directive The directive to update
159
- * @param value The value to set
160
- */
161
- setValue(value: unknown): void;
162
- /**
163
- * User callbacks for implementing logic to release any resources/subscriptions
164
- * that may have been retained by this directive. Since directives may also be
165
- * re-connected, `reconnected` should also be implemented to restore the
166
- * working state of the directive prior to the next render.
167
- */
168
- protected disconnected(): void;
169
- protected reconnected(): void;
170
- }