@vaadin/component-base 24.0.0-alpha6 → 24.0.0-alpha8

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 (58) hide show
  1. package/package.json +2 -2
  2. package/src/a11y-announcer.d.ts +1 -1
  3. package/src/a11y-announcer.js +1 -1
  4. package/src/active-mixin.d.ts +1 -1
  5. package/src/active-mixin.js +1 -1
  6. package/src/browser-utils.js +7 -7
  7. package/src/controller-mixin.d.ts +1 -1
  8. package/src/controller-mixin.js +1 -1
  9. package/src/delegate-focus-mixin.d.ts +48 -0
  10. package/src/delegate-focus-mixin.js +228 -0
  11. package/src/delegate-state-mixin.d.ts +20 -0
  12. package/src/delegate-state-mixin.js +125 -0
  13. package/src/dir-mixin.d.ts +1 -5
  14. package/src/dir-mixin.js +1 -31
  15. package/src/dir-utils.d.ts +19 -0
  16. package/src/dir-utils.js +36 -0
  17. package/src/disabled-mixin.d.ts +1 -1
  18. package/src/disabled-mixin.js +1 -1
  19. package/src/dom-utils.d.ts +1 -1
  20. package/src/dom-utils.js +1 -1
  21. package/src/element-mixin.d.ts +1 -1
  22. package/src/element-mixin.js +11 -5
  23. package/src/focus-mixin.d.ts +1 -1
  24. package/src/focus-mixin.js +1 -1
  25. package/src/focus-trap-controller.d.ts +1 -1
  26. package/src/focus-trap-controller.js +1 -1
  27. package/src/focus-utils.d.ts +1 -1
  28. package/src/focus-utils.js +1 -1
  29. package/src/gestures.js +1 -1
  30. package/src/iron-list-core.js +32 -12
  31. package/src/keyboard-direction-mixin.d.ts +1 -1
  32. package/src/keyboard-direction-mixin.js +1 -1
  33. package/src/keyboard-mixin.d.ts +1 -1
  34. package/src/keyboard-mixin.js +1 -1
  35. package/src/list-mixin.d.ts +1 -1
  36. package/src/list-mixin.js +5 -6
  37. package/src/media-query-controller.d.ts +1 -1
  38. package/src/media-query-controller.js +1 -1
  39. package/src/overflow-controller.d.ts +1 -1
  40. package/src/overflow-controller.js +3 -3
  41. package/src/polylit-mixin.d.ts +1 -1
  42. package/src/polylit-mixin.js +9 -4
  43. package/src/resize-mixin.d.ts +1 -1
  44. package/src/resize-mixin.js +1 -1
  45. package/src/{slot-observe-controller.d.ts → slot-child-observe-controller.d.ts} +2 -2
  46. package/src/{slot-observe-controller.js → slot-child-observe-controller.js} +7 -6
  47. package/src/slot-controller.d.ts +1 -1
  48. package/src/slot-controller.js +4 -4
  49. package/src/tabindex-mixin.d.ts +1 -1
  50. package/src/tabindex-mixin.js +1 -1
  51. package/src/templates.js +1 -1
  52. package/src/tooltip-controller.d.ts +1 -1
  53. package/src/tooltip-controller.js +1 -1
  54. package/src/unique-id-utils.d.ts +1 -1
  55. package/src/unique-id-utils.js +1 -1
  56. package/src/virtualizer-iron-list-adapter.js +65 -9
  57. package/src/dir-helper.d.ts +0 -42
  58. package/src/dir-helper.js +0 -93
package/src/dom-utils.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2023 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 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2023 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 '../custom_typings/vaadin-usage-statistics.js';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2023 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 { setCancelSyntheticClickEvents } from '@polymer/polymer/lib/utils/settings.js';
@@ -15,14 +15,20 @@ import { DirMixin } from './dir-mixin.js';
15
15
  // for buttons that are based on `[role=button]` e.g vaadin-button.
16
16
  setCancelSyntheticClickEvents(false);
17
17
 
18
- window.Vaadin = window.Vaadin || {};
18
+ if (!window.Vaadin) {
19
+ window.Vaadin = {};
20
+ }
19
21
 
20
22
  /**
21
23
  * Array of Vaadin custom element classes that have been finalized.
22
24
  */
23
- window.Vaadin.registrations = window.Vaadin.registrations || [];
25
+ if (!window.Vaadin.registrations) {
26
+ window.Vaadin.registrations = [];
27
+ }
24
28
 
25
- window.Vaadin.developmentModeCallback = window.Vaadin.developmentModeCallback || {};
29
+ if (!window.Vaadin.developmentModeCallback) {
30
+ window.Vaadin.developmentModeCallback = {};
31
+ }
26
32
 
27
33
  window.Vaadin.developmentModeCallback['vaadin-usage-statistics'] = function () {
28
34
  usageStatistics();
@@ -39,7 +45,7 @@ const registered = new Set();
39
45
  export const ElementMixin = (superClass) =>
40
46
  class VaadinElementMixin extends DirMixin(superClass) {
41
47
  static get version() {
42
- return '24.0.0-alpha6';
48
+ return '24.0.0-alpha8';
43
49
  }
44
50
 
45
51
  /** @protected */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2023 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 type { Constructor } from '@open-wc/dedupe-mixin';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2023 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';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2023 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 type { ReactiveController } from 'lit';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2023 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 { getFocusableElements, isElementFocused } from './focus-utils.js';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2023 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 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2023 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
 
package/src/gestures.js CHANGED
@@ -90,7 +90,7 @@ function PASSIVE_TOUCH(eventName) {
90
90
  }
91
91
 
92
92
  // Check for touch-only devices
93
- const IS_TOUCH_ONLY = navigator.userAgent.match(/iP(?:[oa]d|hone)|Android/);
93
+ const IS_TOUCH_ONLY = navigator.userAgent.match(/iP(?:[oa]d|hone)|Android/u);
94
94
 
95
95
  // Defined at https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#enabling-and-disabling-form-controls:-the-disabled-attribute
96
96
  /** @type {!Object<boolean>} */
@@ -10,12 +10,22 @@
10
10
  import { animationFrame, idlePeriod, microTask } from './async.js';
11
11
  import { Debouncer, enqueueDebouncer, flush } from './debounce.js';
12
12
 
13
- const IOS = navigator.userAgent.match(/iP(?:hone|ad;(?: U;)? CPU) OS (\d+)/);
13
+ const IOS = navigator.userAgent.match(/iP(?:hone|ad;(?: U;)? CPU) OS (\d+)/u);
14
14
  const IOS_TOUCH_SCROLLING = IOS && IOS[1] >= 8;
15
15
  const DEFAULT_PHYSICAL_COUNT = 3;
16
16
 
17
17
  /**
18
- * @private
18
+ * DO NOT EDIT THIS FILE!
19
+ *
20
+ * This file includes the iron-list scrolling engine copied from
21
+ * https://github.com/PolymerElements/iron-list/blob/master/iron-list.js
22
+ *
23
+ * If something in the scrolling engine needs to be changed
24
+ * for the virtualizer's purposes, override a function
25
+ * in virtualizer-iron-list-adapter.js instead of changing it here.
26
+ *
27
+ * This will allow us to keep the iron-list code here as close to
28
+ * the original as possible.
19
29
  */
20
30
  export const ironList = {
21
31
  /**
@@ -491,9 +501,12 @@ export const ironList = {
491
501
  this._physicalIndexForKey = {};
492
502
  this._firstVisibleIndexVal = null;
493
503
  this._lastVisibleIndexVal = null;
494
- this._physicalCount = this._physicalCount || 0;
495
- this._physicalItems = this._physicalItems || [];
496
- this._physicalSizes = this._physicalSizes || [];
504
+ if (!this._physicalItems) {
505
+ this._physicalItems = [];
506
+ }
507
+ if (!this._physicalSizes) {
508
+ this._physicalSizes = [];
509
+ }
497
510
  this._physicalStart = 0;
498
511
  if (this._scrollTop > this._scrollOffset) {
499
512
  this._resetScrollPosition(0);
@@ -635,16 +648,21 @@ export const ironList = {
635
648
  * @param {boolean=} forceUpdate If true, updates the height no matter what.
636
649
  */
637
650
  _updateScrollerSize(forceUpdate) {
638
- this._estScrollHeight =
651
+ const estScrollHeight =
639
652
  this._physicalBottom +
640
653
  Math.max(this._virtualCount - this._physicalCount - this._virtualStart, 0) * this._physicalAverage;
641
654
 
642
- forceUpdate = forceUpdate || this._scrollHeight === 0;
643
- forceUpdate = forceUpdate || this._scrollPosition >= this._estScrollHeight - this._physicalSize;
655
+ this._estScrollHeight = estScrollHeight;
656
+
644
657
  // Amortize height adjustment, so it won't trigger large repaints too often.
645
- if (forceUpdate || Math.abs(this._estScrollHeight - this._scrollHeight) >= this._viewportHeight) {
646
- this.$.items.style.height = `${this._estScrollHeight}px`;
647
- this._scrollHeight = this._estScrollHeight;
658
+ if (
659
+ forceUpdate ||
660
+ this._scrollHeight === 0 ||
661
+ this._scrollPosition >= estScrollHeight - this._physicalSize ||
662
+ Math.abs(estScrollHeight - this._scrollHeight) >= this._viewportHeight
663
+ ) {
664
+ this.$.items.style.height = `${estScrollHeight}px`;
665
+ this._scrollHeight = estScrollHeight;
648
666
  }
649
667
  },
650
668
 
@@ -740,7 +758,9 @@ export const ironList = {
740
758
  },
741
759
 
742
760
  _debounce(name, cb, asyncModule) {
743
- this._debouncers = this._debouncers || {};
761
+ if (!this._debouncers) {
762
+ this._debouncers = {};
763
+ }
744
764
  this._debouncers[name] = Debouncer.debounce(this._debouncers[name], asyncModule, cb.bind(this));
745
765
  enqueueDebouncer(this._debouncers[name]);
746
766
  },
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2022 Vaadin Ltd.
3
+ * Copyright (c) 2022 - 2023 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 type { Constructor } from '@open-wc/dedupe-mixin';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2022 Vaadin Ltd.
3
+ * Copyright (c) 2022 - 2023 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 { isElementFocused, isElementHidden } from './focus-utils.js';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2023 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 type { Constructor } from '@open-wc/dedupe-mixin';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2023 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';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2017 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2017 - 2023 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 type { Constructor } from '@open-wc/dedupe-mixin';
package/src/list-mixin.js CHANGED
@@ -1,12 +1,12 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2017 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2017 - 2023 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';
7
7
  import { timeOut } from './async.js';
8
8
  import { Debouncer } from './debounce.js';
9
- import { DirHelper } from './dir-helper.js';
9
+ import { getNormalizedScrollLeft, setNormalizedScrollLeft } from './dir-utils.js';
10
10
  import { KeyboardDirectionMixin } from './keyboard-direction-mixin.js';
11
11
 
12
12
  /**
@@ -213,7 +213,7 @@ export const ListMixin = (superClass) =>
213
213
  const key = event.key;
214
214
 
215
215
  const currentIdx = this.items.indexOf(this.focused);
216
- if (/[a-zA-Z0-9]/.test(key) && key.length === 1) {
216
+ if (/[a-zA-Z0-9]/u.test(key) && key.length === 1) {
217
217
  const idx = this._searchKey(currentIdx, key);
218
218
  if (idx >= 0) {
219
219
  this._focus(idx);
@@ -327,9 +327,8 @@ export const ListMixin = (superClass) =>
327
327
  this._scrollerElement.scrollTop += pixels;
328
328
  } else {
329
329
  const dir = this.getAttribute('dir') || 'ltr';
330
- const scrollType = DirHelper.detectScrollType();
331
- const scrollLeft = DirHelper.getNormalizedScrollLeft(scrollType, dir, this._scrollerElement) + pixels;
332
- DirHelper.setNormalizedScrollLeft(scrollType, dir, this._scrollerElement, scrollLeft);
330
+ const scrollLeft = getNormalizedScrollLeft(this._scrollerElement, dir) + pixels;
331
+ setNormalizedScrollLeft(this._scrollerElement, dir, scrollLeft);
333
332
  }
334
333
  }
335
334
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2023 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 type { ReactiveController } from 'lit';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2023 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 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2023 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 type { ReactiveController } from 'lit';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2023 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';
@@ -92,7 +92,7 @@ export class OverflowController {
92
92
  overflow += ' top';
93
93
  }
94
94
 
95
- if (target.scrollTop < target.scrollHeight - target.clientHeight) {
95
+ if (Math.ceil(target.scrollTop) < Math.ceil(target.scrollHeight - target.clientHeight)) {
96
96
  overflow += ' bottom';
97
97
  }
98
98
 
@@ -101,7 +101,7 @@ export class OverflowController {
101
101
  overflow += ' start';
102
102
  }
103
103
 
104
- if (scrollLeft < target.scrollWidth - target.clientWidth) {
104
+ if (Math.ceil(scrollLeft) < Math.ceil(target.scrollWidth - target.clientWidth)) {
105
105
  overflow += ' end';
106
106
  }
107
107
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2023 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 type { Constructor } from '@open-wc/dedupe-mixin';
@@ -1,16 +1,18 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2023 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 { dedupeMixin } from '@open-wc/dedupe-mixin';
7
7
 
8
8
  const caseMap = {};
9
9
 
10
- const CAMEL_TO_DASH = /([A-Z])/g;
10
+ const CAMEL_TO_DASH = /([A-Z])/gu;
11
11
 
12
12
  function camelToDash(camel) {
13
- caseMap[camel] = caseMap[camel] || camel.replace(CAMEL_TO_DASH, '-$1').toLowerCase();
13
+ if (!caseMap[camel]) {
14
+ caseMap[camel] = camel.replace(CAMEL_TO_DASH, '-$1').toLowerCase();
15
+ }
14
16
  return caseMap[camel];
15
17
  }
16
18
 
@@ -169,7 +171,10 @@ const PolylitMixinImplementation = (superclass) => {
169
171
  firstUpdated() {
170
172
  super.firstUpdated();
171
173
 
172
- this.$ = this.$ || {};
174
+ if (!this.$) {
175
+ this.$ = {};
176
+ }
177
+
173
178
  this.shadowRoot.querySelectorAll('[id]').forEach((node) => {
174
179
  this.$[node.id] = node;
175
180
  });
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2023 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 type { Constructor } from '@open-wc/dedupe-mixin';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2023 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';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2022 Vaadin Ltd.
3
+ * Copyright (c) 2022 - 2023 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 { SlotController } from './slot-controller.js';
@@ -9,7 +9,7 @@ import { SlotController } from './slot-controller.js';
9
9
  * A controller that observes slotted element mutations, especially ID attribute
10
10
  * and the text content, and fires an event to notify host element about those.
11
11
  */
12
- export class SlotObserveController extends SlotController {
12
+ export class SlotChildObserveController extends SlotController {
13
13
  /**
14
14
  * Setup the mutation observer on the node to update ID and notify host.
15
15
  * Node doesn't get observed automatically until this method is called.
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2022 Vaadin Ltd.
3
+ * Copyright (c) 2022 - 2023 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 { SlotController } from './slot-controller.js';
@@ -9,7 +9,7 @@ import { SlotController } from './slot-controller.js';
9
9
  * A controller that observes slotted element mutations, especially ID attribute
10
10
  * and the text content, and fires an event to notify host element about those.
11
11
  */
12
- export class SlotObserveController extends SlotController {
12
+ export class SlotChildObserveController extends SlotController {
13
13
  constructor(host, slot, tagName, config = {}) {
14
14
  super(host, slot, tagName, { ...config, useUniqueId: true });
15
15
  }
@@ -107,7 +107,7 @@ export class SlotObserveController extends SlotController {
107
107
  if (mutation.type === 'attributes') {
108
108
  // We use attributeFilter to only observe ID mutation,
109
109
  // no need to check for attribute name separately.
110
- if (isCurrentNodeMutation && target.id !== this.defaultId) {
110
+ if (isCurrentNodeMutation) {
111
111
  this.__updateNodeId(target);
112
112
  }
113
113
  } else if (isCurrentNodeMutation || target.parentElement === this.node) {
@@ -141,8 +141,7 @@ export class SlotObserveController extends SlotController {
141
141
  }
142
142
 
143
143
  return (
144
- node.children.length > 0 ||
145
- (node.nodeType === Node.ELEMENT_NODE && customElements.get(node.localName)) ||
144
+ (node.nodeType === Node.ELEMENT_NODE && (customElements.get(node.localName) || node.children.length > 0)) ||
146
145
  (node.textContent && node.textContent.trim() !== '')
147
146
  );
148
147
  }
@@ -168,7 +167,9 @@ export class SlotObserveController extends SlotController {
168
167
  * @private
169
168
  */
170
169
  __updateNodeId(node) {
171
- if (node.nodeType === Node.ELEMENT_NODE && !node.id) {
170
+ // When in multiple mode, only set ID attribute on the element in default slot.
171
+ const isFirstNode = !this.nodes || node === this.nodes[0];
172
+ if (node.nodeType === Node.ELEMENT_NODE && isFirstNode && !node.id) {
172
173
  node.id = this.defaultId;
173
174
  }
174
175
  }
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2023 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 type { ReactiveController } from 'lit';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2023 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';
@@ -14,12 +14,12 @@ export class SlotController extends EventTarget {
14
14
  /**
15
15
  * Ensure that every instance has unique ID.
16
16
  *
17
- * @param {string} slotName
18
17
  * @param {HTMLElement} host
18
+ * @param {string} slotName
19
19
  * @return {string}
20
20
  * @protected
21
21
  */
22
- static generateId(slotName, host) {
22
+ static generateId(host, slotName) {
23
23
  const prefix = slotName || 'default';
24
24
  return `${prefix}-${host.localName}-${generateUniqueId()}`;
25
25
  }
@@ -42,7 +42,7 @@ export class SlotController extends EventTarget {
42
42
 
43
43
  // Only generate the default ID if requested by the controller.
44
44
  if (useUniqueId) {
45
- this.defaultId = SlotController.generateId(slotName, host);
45
+ this.defaultId = this.constructor.generateId(host, slotName);
46
46
  }
47
47
  }
48
48
 
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2023 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 type { Constructor } from '@open-wc/dedupe-mixin';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2023 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 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2023 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) 2022 Vaadin Ltd.
3
+ * Copyright (c) 2022 - 2023 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 { SlotController } from './slot-controller.js';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2022 Vaadin Ltd.
3
+ * Copyright (c) 2022 - 2023 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 { SlotController } from './slot-controller.js';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2023 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 - 2022 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2023 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6