@vaadin/component-base 22.0.2 → 23.0.0-alpha4

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 (42) hide show
  1. package/index.d.ts +1 -0
  2. package/index.js +1 -0
  3. package/package.json +3 -2
  4. package/src/a11y-announcer.d.ts +10 -0
  5. package/src/a11y-announcer.js +32 -0
  6. package/src/active-mixin.d.ts +1 -1
  7. package/src/active-mixin.js +5 -5
  8. package/src/async.js +8 -5
  9. package/src/browser-utils.js +1 -1
  10. package/src/controller-mixin.d.ts +1 -1
  11. package/src/controller-mixin.js +1 -1
  12. package/src/debounce.js +10 -4
  13. package/src/dir-helper.d.ts +1 -1
  14. package/src/dir-helper.js +3 -2
  15. package/src/dir-mixin.d.ts +1 -1
  16. package/src/dir-mixin.js +7 -7
  17. package/src/disabled-mixin.d.ts +1 -1
  18. package/src/disabled-mixin.js +1 -1
  19. package/src/element-mixin.d.ts +1 -1
  20. package/src/element-mixin.js +2 -2
  21. package/src/focus-mixin.d.ts +1 -1
  22. package/src/focus-mixin.js +1 -1
  23. package/src/focus-trap-controller.d.ts +39 -0
  24. package/src/focus-trap-controller.js +139 -0
  25. package/src/focus-utils.d.ts +45 -0
  26. package/src/focus-utils.js +228 -0
  27. package/src/gestures.d.ts +76 -0
  28. package/src/gestures.js +932 -0
  29. package/src/iron-list-core.js +40 -38
  30. package/src/keyboard-mixin.d.ts +1 -1
  31. package/src/keyboard-mixin.js +1 -1
  32. package/src/resize-mixin.d.ts +19 -0
  33. package/src/resize-mixin.js +56 -0
  34. package/src/slot-controller.d.ts +8 -2
  35. package/src/slot-controller.js +74 -27
  36. package/src/slot-mixin.d.ts +1 -1
  37. package/src/slot-mixin.js +11 -3
  38. package/src/tabindex-mixin.d.ts +1 -1
  39. package/src/tabindex-mixin.js +1 -1
  40. package/src/templates.js +1 -1
  41. package/src/virtualizer-iron-list-adapter.js +5 -6
  42. package/src/virtualizer.js +6 -6
@@ -186,36 +186,36 @@ export const ironList = {
186
186
  return Math.max(0, virtualCount - this._physicalCount);
187
187
  },
188
188
 
189
+ get _virtualStart() {
190
+ return this._virtualStartVal || 0;
191
+ },
192
+
189
193
  set _virtualStart(val) {
190
194
  val = this._clamp(val, 0, this._maxVirtualStart);
191
195
  if (this.grid) {
192
- val = val - (val % this._itemsPerRow);
196
+ val -= val % this._itemsPerRow;
193
197
  }
194
198
  this._virtualStartVal = val;
195
199
  },
196
200
 
197
- get _virtualStart() {
198
- return this._virtualStartVal || 0;
201
+ get _physicalStart() {
202
+ return this._physicalStartVal || 0;
199
203
  },
200
204
 
201
205
  /**
202
206
  * The k-th tile that is at the top of the scrolling list.
203
207
  */
204
208
  set _physicalStart(val) {
205
- val = val % this._physicalCount;
209
+ val %= this._physicalCount;
206
210
  if (val < 0) {
207
211
  val = this._physicalCount + val;
208
212
  }
209
213
  if (this.grid) {
210
- val = val - (val % this._itemsPerRow);
214
+ val -= val % this._itemsPerRow;
211
215
  }
212
216
  this._physicalStartVal = val;
213
217
  },
214
218
 
215
- get _physicalStart() {
216
- return this._physicalStartVal || 0;
217
- },
218
-
219
219
  /**
220
220
  * The k-th tile that is at the bottom of the scrolling list.
221
221
  */
@@ -223,14 +223,14 @@ export const ironList = {
223
223
  return (this._physicalStart + this._physicalCount - 1) % this._physicalCount;
224
224
  },
225
225
 
226
- set _physicalCount(val) {
227
- this._physicalCountVal = val;
228
- },
229
-
230
226
  get _physicalCount() {
231
227
  return this._physicalCountVal || 0;
232
228
  },
233
229
 
230
+ set _physicalCount(val) {
231
+ this._physicalCountVal = val;
232
+ },
233
+
234
234
  /**
235
235
  * An optimal physical size such that we will have enough physical items
236
236
  * to fill up the viewport and recycle when the user scrolls.
@@ -260,7 +260,7 @@ export const ironList = {
260
260
  var physicalOffset = this._physicalTop + this._scrollOffset;
261
261
 
262
262
  idx =
263
- this._iterateItems(function (pidx, vidx) {
263
+ this._iterateItems((pidx, vidx) => {
264
264
  physicalOffset += this._getPhysicalSizeIncrement(pidx);
265
265
 
266
266
  if (physicalOffset > this._scrollPosition) {
@@ -288,7 +288,7 @@ export const ironList = {
288
288
  idx = Math.min(this._virtualCount, this.firstVisibleIndex + this._estRowsInView * this._itemsPerRow - 1);
289
289
  } else {
290
290
  var physicalOffset = this._physicalTop + this._scrollOffset;
291
- this._iterateItems(function (pidx, vidx) {
291
+ this._iterateItems((pidx, vidx) => {
292
292
  if (physicalOffset < this._scrollBottom) {
293
293
  idx = vidx;
294
294
  }
@@ -334,10 +334,10 @@ export const ironList = {
334
334
  this._lastVisibleIndexVal = null;
335
335
  // Random access.
336
336
  if (Math.abs(delta) > this._physicalSize && this._physicalSize > 0) {
337
- delta = delta - this._scrollOffset;
337
+ delta -= this._scrollOffset;
338
338
  var idxAdjustment = Math.round(delta / this._physicalAverage) * this._itemsPerRow;
339
- this._virtualStart = this._virtualStart + idxAdjustment;
340
- this._physicalStart = this._physicalStart + idxAdjustment;
339
+ this._virtualStart += idxAdjustment;
340
+ this._physicalStart += idxAdjustment;
341
341
  // Estimate new physical offset based on the virtual start index.
342
342
  // adjusts the physical start position to stay in sync with the clamped
343
343
  // virtual start index. It's critical not to let this value be
@@ -353,11 +353,11 @@ export const ironList = {
353
353
  var reusables = this._getReusables(isScrollingDown);
354
354
  if (isScrollingDown) {
355
355
  this._physicalTop = reusables.physicalTop;
356
- this._virtualStart = this._virtualStart + reusables.indexes.length;
357
- this._physicalStart = this._physicalStart + reusables.indexes.length;
356
+ this._virtualStart += reusables.indexes.length;
357
+ this._physicalStart += reusables.indexes.length;
358
358
  } else {
359
- this._virtualStart = this._virtualStart - reusables.indexes.length;
360
- this._physicalStart = this._physicalStart - reusables.indexes.length;
359
+ this._virtualStart -= reusables.indexes.length;
360
+ this._physicalStart -= reusables.indexes.length;
361
361
  }
362
362
  this._update(reusables.indexes, isScrollingDown ? null : reusables.indexes);
363
363
  this._debounce('_increasePoolIfNeeded', this._increasePoolIfNeeded.bind(this, 0), microTask);
@@ -396,7 +396,7 @@ export const ironList = {
396
396
  // eslint-disable-next-line no-constant-condition
397
397
  while (true) {
398
398
  physicalItemHeight = this._getPhysicalSizeIncrement(ith);
399
- offsetContent = offsetContent - physicalItemHeight;
399
+ offsetContent -= physicalItemHeight;
400
400
  if (idxs.length >= physicalCount || offsetContent <= protectedOffsetContent) {
401
401
  break;
402
402
  }
@@ -410,7 +410,7 @@ export const ironList = {
410
410
  break;
411
411
  }
412
412
  idxs.push(ith);
413
- top = top + physicalItemHeight;
413
+ top += physicalItemHeight;
414
414
  ith = (ith + 1) % physicalCount;
415
415
  } else {
416
416
  // Check that index is within the valid range.
@@ -422,7 +422,7 @@ export const ironList = {
422
422
  break;
423
423
  }
424
424
  idxs.push(ith);
425
- top = top - physicalItemHeight;
425
+ top -= physicalItemHeight;
426
426
  ith = ith === 0 ? physicalCount - 1 : ith - 1;
427
427
  }
428
428
  }
@@ -492,7 +492,7 @@ export const ironList = {
492
492
  for (var i = 0; i < delta; i++) {
493
493
  this._physicalSizes.push(0);
494
494
  }
495
- this._physicalCount = this._physicalCount + delta;
495
+ this._physicalCount += delta;
496
496
  // Update the physical start if it needs to preserve the model of the
497
497
  // focused item. In this situation, the focused item is currently rendered
498
498
  // and its model would have changed after increasing the pool if the
@@ -502,7 +502,7 @@ export const ironList = {
502
502
  this._isIndexRendered(this._focusedVirtualIndex) &&
503
503
  this._getPhysicalIndex(this._focusedVirtualIndex) < this._physicalEnd
504
504
  ) {
505
- this._physicalStart = this._physicalStart + delta;
505
+ this._physicalStart += delta;
506
506
  }
507
507
  this._update();
508
508
  this._templateCost = (window.performance.now() - ts) / delta;
@@ -535,8 +535,8 @@ export const ironList = {
535
535
  if (this._physicalCount !== 0) {
536
536
  var reusables = this._getReusables(true);
537
537
  this._physicalTop = reusables.physicalTop;
538
- this._virtualStart = this._virtualStart + reusables.indexes.length;
539
- this._physicalStart = this._physicalStart + reusables.indexes.length;
538
+ this._virtualStart += reusables.indexes.length;
539
+ this._physicalStart += reusables.indexes.length;
540
540
  this._update(reusables.indexes);
541
541
  this._update();
542
542
  this._increasePoolIfNeeded(0);
@@ -548,7 +548,9 @@ export const ironList = {
548
548
  },
549
549
 
550
550
  _gridChanged: function (newGrid, oldGrid) {
551
- if (typeof oldGrid === 'undefined') return;
551
+ if (typeof oldGrid === 'undefined') {
552
+ return;
553
+ }
552
554
  this.notifyResize();
553
555
  flush();
554
556
  newGrid && this._updateGridMetrics();
@@ -666,7 +668,7 @@ export const ironList = {
666
668
  var prevPhysicalAvg = this._physicalAverage;
667
669
 
668
670
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
669
- this._iterateItems(function (pidx, vidx) {
671
+ this._iterateItems((pidx, vidx) => {
670
672
  oldPhysicalSize += this._physicalSizes[pidx];
671
673
  this._physicalSizes[pidx] = this._physicalItems[pidx].offsetHeight;
672
674
  newPhysicalSize += this._physicalSizes[pidx];
@@ -710,11 +712,11 @@ export const ironList = {
710
712
  var totalItemWidth = this._itemsPerRow * this._itemWidth;
711
713
  var rowOffset = (this._viewportWidth - totalItemWidth) / 2;
712
714
 
713
- this._iterateItems(function (pidx, vidx) {
715
+ this._iterateItems((pidx, vidx) => {
714
716
  var modulus = vidx % this._itemsPerRow;
715
717
  var x = Math.floor(modulus * this._itemWidth + rowOffset);
716
718
  if (this._isRTL) {
717
- x = x * -1;
719
+ x *= -1;
718
720
  }
719
721
  this.translate3d(x + 'px', y + 'px', 0, this._physicalItems[pidx]);
720
722
  if (this._shouldRenderNextRow(vidx)) {
@@ -724,7 +726,7 @@ export const ironList = {
724
726
  } else {
725
727
  const order = [];
726
728
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
727
- this._iterateItems(function (pidx, vidx) {
729
+ this._iterateItems((pidx, vidx) => {
728
730
  const item = this._physicalItems[pidx];
729
731
  this.translate3d(0, y + 'px', 0, item);
730
732
  y += this._physicalSizes[pidx];
@@ -769,7 +771,7 @@ export const ironList = {
769
771
  this._virtualStart === 0 ? this._physicalTop : Math.min(this._scrollPosition + this._physicalTop, 0);
770
772
  // Note: the delta can be positive or negative.
771
773
  if (deltaHeight !== 0) {
772
- this._physicalTop = this._physicalTop - deltaHeight;
774
+ this._physicalTop -= deltaHeight;
773
775
  // This may be called outside of a scrollHandler, so use last cached position
774
776
  var scrollTop = this._scrollPosition;
775
777
  // juking scroll position during interial scrolling on iOS is no bueno
@@ -845,9 +847,9 @@ export const ironList = {
845
847
  var hiddenContentSize = this._hiddenContentSize;
846
848
  // scroll to the item as much as we can.
847
849
  while (currentVirtualItem < idx && targetOffsetTop <= hiddenContentSize) {
848
- targetOffsetTop = targetOffsetTop + this._getPhysicalSizeIncrement(currentTopItem);
850
+ targetOffsetTop += this._getPhysicalSizeIncrement(currentTopItem);
849
851
  currentTopItem = (currentTopItem + 1) % this._physicalCount;
850
- currentVirtualItem++;
852
+ currentVirtualItem += 1;
851
853
  }
852
854
  this._updateScrollerSize(true);
853
855
  this._positionItems();
@@ -873,7 +875,7 @@ export const ironList = {
873
875
  _resizeHandler: function () {
874
876
  this._debounce(
875
877
  '_render',
876
- function () {
878
+ () => {
877
879
  // clear cached visible index.
878
880
  this._firstVisibleIndexVal = null;
879
881
  this._lastVisibleIndexVal = null;
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { Constructor } from '@open-wc/dedupe-mixin';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { dedupingMixin } from '@polymer/polymer/lib/utils/mixin.js';
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2021 - 2022 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import { Constructor } from '@open-wc/dedupe-mixin';
7
+
8
+ /**
9
+ * A mixin that uses a ResizeObserver to listen to host size changes.
10
+ */
11
+ export declare function ResizeMixin<T extends Constructor<HTMLElement>>(base: T): T & Constructor<ResizeMixinClass>;
12
+
13
+ export declare class ResizeMixinClass {
14
+ /**
15
+ * A handler invoked on host resize. By default, it does nothing.
16
+ * Override the method to implement your own behavior.
17
+ */
18
+ protected _onResize(contentRect: DOMRect): void;
19
+ }
@@ -0,0 +1,56 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2021 - 2022 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import { dedupingMixin } from '@polymer/polymer/lib/utils/mixin.js';
7
+
8
+ const observer = new ResizeObserver((entries) => {
9
+ setTimeout(() => {
10
+ entries.forEach((entry) => {
11
+ entry.target._onResize(entry.contentRect);
12
+ });
13
+ });
14
+ });
15
+
16
+ /**
17
+ * A mixin that uses a ResizeObserver to listen to host size changes.
18
+ *
19
+ * @polymerMixin
20
+ */
21
+ export const ResizeMixin = dedupingMixin(
22
+ (superclass) =>
23
+ class ResizeMixinClass extends superclass {
24
+ /** @protected */
25
+ connectedCallback() {
26
+ super.connectedCallback();
27
+ observer.observe(this);
28
+ }
29
+
30
+ /** @protected */
31
+ disconnectedCallback() {
32
+ super.disconnectedCallback();
33
+ observer.unobserve(this);
34
+ }
35
+
36
+ /**
37
+ * A handler invoked on host resize. By default, it does nothing.
38
+ * Override the method to implement your own behavior.
39
+ *
40
+ * @protected
41
+ */
42
+ _onResize(_contentRect) {
43
+ // To be implemented.
44
+ }
45
+
46
+ /**
47
+ * @deprecated Since Vaadin 23, `notifyResize()` is deprecated. The component uses a
48
+ * ResizeObserver internally and doesn't need to be explicitly notified of resizes.
49
+ */
50
+ notifyResize() {
51
+ console.warn(
52
+ `WARNING: Since Vaadin 23, notifyResize() is deprecated. The component uses a ResizeObserver internally and doesn't need to be explicitly notified of resizes.`
53
+ );
54
+ }
55
+ }
56
+ );
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { ReactiveController } from 'lit';
7
7
 
8
- export class SlotController implements ReactiveController {
8
+ export class SlotController extends EventTarget implements ReactiveController {
9
9
  constructor(
10
10
  host: HTMLElement,
11
11
  slotName: string,
@@ -34,6 +34,12 @@ export class SlotController implements ReactiveController {
34
34
 
35
35
  protected defaultNode: Node;
36
36
 
37
+ protected defaultId: string;
38
+
39
+ protected attachDefaultNode(): Node | undefined;
40
+
41
+ protected initNode(node: Node): void;
42
+
37
43
  /**
38
44
  * Override to initialize the newly added custom node.
39
45
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { FlattenedNodesObserver } from '@polymer/polymer/lib/utils/flattened-nodes-observer.js';
@@ -8,44 +8,46 @@ import { FlattenedNodesObserver } from '@polymer/polymer/lib/utils/flattened-nod
8
8
  /**
9
9
  * A controller for providing content to slot element and observing changes.
10
10
  */
11
- export class SlotController {
11
+ export class SlotController extends EventTarget {
12
12
  constructor(host, slotName, slotFactory, slotInitializer) {
13
+ super();
14
+
13
15
  this.host = host;
14
16
  this.slotName = slotName;
15
17
  this.slotFactory = slotFactory;
16
18
  this.slotInitializer = slotInitializer;
19
+ this.defaultId = SlotController.generateId(slotName, host);
20
+ }
21
+
22
+ /**
23
+ * Ensure that every instance has unique ID.
24
+ *
25
+ * @param {string} slotName
26
+ * @param {HTMLElement} host
27
+ * @return {string}
28
+ * @protected
29
+ */
30
+ static generateId(slotName, host) {
31
+ const prefix = slotName || 'default';
32
+
33
+ // Maintain the unique ID counter for a given prefix.
34
+ this[`${prefix}Id`] = 1 + this[`${prefix}Id`] || 0;
35
+
36
+ return `${prefix}-${host.localName}-${this[`${prefix}Id`]}`;
17
37
  }
18
38
 
19
39
  hostConnected() {
20
40
  if (!this.initialized) {
21
- const { host, slotName, slotFactory, slotInitializer } = this;
22
-
23
- const slotted = this.getSlotChild();
24
-
25
- if (!slotted) {
26
- // Slot factory is optional, some slots don't have default content.
27
- if (slotFactory) {
28
- const slotContent = slotFactory(host);
29
- if (slotContent instanceof Element) {
30
- if (slotName !== '') {
31
- slotContent.setAttribute('slot', slotName);
32
- }
33
- host.appendChild(slotContent);
34
- this.node = slotContent;
35
-
36
- // Store reference to not pass default node to `initCustomNode`.
37
- this.defaultNode = slotContent;
38
- }
39
- }
41
+ let node = this.getSlotChild();
42
+
43
+ if (!node) {
44
+ node = this.attachDefaultNode();
40
45
  } else {
41
- this.node = slotted;
46
+ this.node = node;
47
+ this.initCustomNode(node);
42
48
  }
43
49
 
44
- // Don't try to bind `this` to initializer (normally it's arrow function).
45
- // Instead, pass the host as a first argument to access component's state.
46
- if (slotInitializer) {
47
- slotInitializer(host, this.node);
48
- }
50
+ this.initNode(node);
49
51
 
50
52
  // TODO: Consider making this behavior opt-in to improve performance.
51
53
  this.observe();
@@ -54,6 +56,36 @@ export class SlotController {
54
56
  }
55
57
  }
56
58
 
59
+ /**
60
+ * Create and attach default node using the slot factory.
61
+ * @return {Node | undefined}
62
+ * @protected
63
+ */
64
+ attachDefaultNode() {
65
+ const { host, slotName, slotFactory } = this;
66
+
67
+ // Check if the node was created previously and if so, reuse it.
68
+ let node = this.defaultNode;
69
+
70
+ // Slot factory is optional, some slots don't have default content.
71
+ if (!node && slotFactory) {
72
+ node = slotFactory(host);
73
+ if (node instanceof Element) {
74
+ if (slotName !== '') {
75
+ node.setAttribute('slot', slotName);
76
+ }
77
+ this.node = node;
78
+ this.defaultNode = node;
79
+ }
80
+ }
81
+
82
+ if (node) {
83
+ host.appendChild(node);
84
+ }
85
+
86
+ return node;
87
+ }
88
+
57
89
  /**
58
90
  * Return a reference to the node managed by the controller.
59
91
  * @return {Node}
@@ -69,6 +101,19 @@ export class SlotController {
69
101
  });
70
102
  }
71
103
 
104
+ /**
105
+ * @param {Node} node
106
+ * @protected
107
+ */
108
+ initNode(node) {
109
+ const { slotInitializer } = this;
110
+ // Don't try to bind `this` to initializer (normally it's arrow function).
111
+ // Instead, pass the host as a first argument to access component's state.
112
+ if (slotInitializer) {
113
+ slotInitializer(this.host, node);
114
+ }
115
+ }
116
+
72
117
  /**
73
118
  * Override to initialize the newly added custom node.
74
119
  *
@@ -115,6 +160,8 @@ export class SlotController {
115
160
 
116
161
  if (newNode !== this.defaultNode) {
117
162
  this.initCustomNode(newNode);
163
+
164
+ this.initNode(newNode);
118
165
  }
119
166
  }
120
167
  });
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { Constructor } from '@open-wc/dedupe-mixin';
package/src/slot-mixin.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { dedupingMixin } from '@polymer/polymer/lib/utils/mixin.js';
@@ -37,7 +37,9 @@ export const SlotMixin = dedupingMixin(
37
37
  const slotFactory = this.slots[slotName];
38
38
  const slotContent = slotFactory();
39
39
  if (slotContent instanceof Element) {
40
- slotContent.setAttribute('slot', slotName);
40
+ if (slotName !== '') {
41
+ slotContent.setAttribute('slot', slotName);
42
+ }
41
43
  this.appendChild(slotContent);
42
44
  }
43
45
  }
@@ -46,7 +48,13 @@ export const SlotMixin = dedupingMixin(
46
48
 
47
49
  /** @protected */
48
50
  _getDirectSlotChild(slotName) {
49
- return Array.from(this.children).find((el) => el.slot === slotName);
51
+ return Array.from(this.childNodes).find((node) => {
52
+ // Either an element (any slot) or a text node (only un-named slot).
53
+ return (
54
+ (node.nodeType === Node.ELEMENT_NODE && node.slot === slotName) ||
55
+ (node.nodeType === Node.TEXT_NODE && node.textContent.trim() && slotName === '')
56
+ );
57
+ });
50
58
  }
51
59
  }
52
60
  );
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { Constructor } from '@open-wc/dedupe-mixin';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { DisabledMixin } from './disabled-mixin.js';
package/src/templates.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { animationFrame, timeOut } from './async.js';
@@ -155,6 +155,10 @@ export class IronListAdapter {
155
155
  return element ? this.scrollTarget.getBoundingClientRect().top - element.getBoundingClientRect().top : undefined;
156
156
  }
157
157
 
158
+ get size() {
159
+ return this.__size;
160
+ }
161
+
158
162
  set size(size) {
159
163
  if (size === this.size) {
160
164
  return;
@@ -204,10 +208,6 @@ export class IronListAdapter {
204
208
  flush();
205
209
  }
206
210
 
207
- get size() {
208
- return this.__size;
209
- }
210
-
211
211
  /** @private */
212
212
  get _scrollTop() {
213
213
  return this.scrollTarget.scrollTop;
@@ -466,7 +466,6 @@ export class IronListAdapter {
466
466
  this._vidxOffset = 0;
467
467
  } else if (this.__skipNextVirtualIndexAdjust) {
468
468
  this.__skipNextVirtualIndexAdjust = false;
469
- return;
470
469
  } else if (Math.abs(delta) > 10000) {
471
470
  // Process a large scroll position change
472
471
  const scale = this._scrollTop / (this.scrollTarget.scrollHeight - this.scrollTarget.offsetHeight);
@@ -17,18 +17,18 @@ export class Virtualizer {
17
17
 
18
18
  /**
19
19
  * The size of the virtualizer
20
- * @param {number} size The size of the virtualizer
20
+ * @return {number | undefined} The size of the virtualizer
21
21
  */
22
- set size(size) {
23
- this.__adapter.size = size;
22
+ get size() {
23
+ return this.__adapter.size;
24
24
  }
25
25
 
26
26
  /**
27
27
  * The size of the virtualizer
28
- * @return {number | undefined} The size of the virtualizer
28
+ * @param {number} size The size of the virtualizer
29
29
  */
30
- get size() {
31
- return this.__adapter.size;
30
+ set size(size) {
31
+ this.__adapter.size = size;
32
32
  }
33
33
 
34
34
  /**