@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.
- package/package.json +2 -2
- package/src/a11y-announcer.d.ts +1 -1
- package/src/a11y-announcer.js +1 -1
- package/src/active-mixin.d.ts +1 -1
- package/src/active-mixin.js +1 -1
- package/src/browser-utils.js +7 -7
- package/src/controller-mixin.d.ts +1 -1
- package/src/controller-mixin.js +1 -1
- package/src/delegate-focus-mixin.d.ts +48 -0
- package/src/delegate-focus-mixin.js +228 -0
- package/src/delegate-state-mixin.d.ts +20 -0
- package/src/delegate-state-mixin.js +125 -0
- package/src/dir-mixin.d.ts +1 -5
- package/src/dir-mixin.js +1 -31
- package/src/dir-utils.d.ts +19 -0
- package/src/dir-utils.js +36 -0
- package/src/disabled-mixin.d.ts +1 -1
- package/src/disabled-mixin.js +1 -1
- package/src/dom-utils.d.ts +1 -1
- package/src/dom-utils.js +1 -1
- package/src/element-mixin.d.ts +1 -1
- package/src/element-mixin.js +11 -5
- package/src/focus-mixin.d.ts +1 -1
- package/src/focus-mixin.js +1 -1
- package/src/focus-trap-controller.d.ts +1 -1
- package/src/focus-trap-controller.js +1 -1
- package/src/focus-utils.d.ts +1 -1
- package/src/focus-utils.js +1 -1
- package/src/gestures.js +1 -1
- package/src/iron-list-core.js +32 -12
- package/src/keyboard-direction-mixin.d.ts +1 -1
- package/src/keyboard-direction-mixin.js +1 -1
- package/src/keyboard-mixin.d.ts +1 -1
- package/src/keyboard-mixin.js +1 -1
- package/src/list-mixin.d.ts +1 -1
- package/src/list-mixin.js +5 -6
- package/src/media-query-controller.d.ts +1 -1
- package/src/media-query-controller.js +1 -1
- package/src/overflow-controller.d.ts +1 -1
- package/src/overflow-controller.js +3 -3
- package/src/polylit-mixin.d.ts +1 -1
- package/src/polylit-mixin.js +9 -4
- package/src/resize-mixin.d.ts +1 -1
- package/src/resize-mixin.js +1 -1
- package/src/{slot-observe-controller.d.ts → slot-child-observe-controller.d.ts} +2 -2
- package/src/{slot-observe-controller.js → slot-child-observe-controller.js} +7 -6
- package/src/slot-controller.d.ts +1 -1
- package/src/slot-controller.js +4 -4
- package/src/tabindex-mixin.d.ts +1 -1
- package/src/tabindex-mixin.js +1 -1
- package/src/templates.js +1 -1
- package/src/tooltip-controller.d.ts +1 -1
- package/src/tooltip-controller.js +1 -1
- package/src/unique-id-utils.d.ts +1 -1
- package/src/unique-id-utils.js +1 -1
- package/src/virtualizer-iron-list-adapter.js +65 -9
- package/src/dir-helper.d.ts +0 -42
- package/src/dir-helper.js +0 -93
package/src/dom-utils.js
CHANGED
package/src/element-mixin.d.ts
CHANGED
package/src/element-mixin.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2021 -
|
|
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
|
-
|
|
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
|
-
|
|
25
|
+
if (!window.Vaadin.registrations) {
|
|
26
|
+
window.Vaadin.registrations = [];
|
|
27
|
+
}
|
|
24
28
|
|
|
25
|
-
|
|
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-
|
|
48
|
+
return '24.0.0-alpha8';
|
|
43
49
|
}
|
|
44
50
|
|
|
45
51
|
/** @protected */
|
package/src/focus-mixin.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2021 -
|
|
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';
|
package/src/focus-mixin.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2021 -
|
|
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 -
|
|
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';
|
package/src/focus-utils.d.ts
CHANGED
package/src/focus-utils.js
CHANGED
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>} */
|
package/src/iron-list-core.js
CHANGED
|
@@ -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
|
-
*
|
|
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
|
-
|
|
495
|
-
|
|
496
|
-
|
|
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
|
-
|
|
651
|
+
const estScrollHeight =
|
|
639
652
|
this._physicalBottom +
|
|
640
653
|
Math.max(this._virtualCount - this._physicalCount - this._virtualStart, 0) * this._physicalAverage;
|
|
641
654
|
|
|
642
|
-
|
|
643
|
-
|
|
655
|
+
this._estScrollHeight = estScrollHeight;
|
|
656
|
+
|
|
644
657
|
// Amortize height adjustment, so it won't trigger large repaints too often.
|
|
645
|
-
if (
|
|
646
|
-
|
|
647
|
-
this._scrollHeight
|
|
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
|
-
|
|
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 { isElementFocused, isElementHidden } from './focus-utils.js';
|
package/src/keyboard-mixin.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2021 -
|
|
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';
|
package/src/keyboard-mixin.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2021 -
|
|
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';
|
package/src/list-mixin.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2017 -
|
|
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 -
|
|
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 {
|
|
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]
|
|
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
|
|
331
|
-
|
|
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 -
|
|
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
|
|
package/src/polylit-mixin.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2021 -
|
|
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';
|
package/src/polylit-mixin.js
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2021 -
|
|
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])/
|
|
10
|
+
const CAMEL_TO_DASH = /([A-Z])/gu;
|
|
11
11
|
|
|
12
12
|
function camelToDash(camel) {
|
|
13
|
-
|
|
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
|
-
|
|
174
|
+
if (!this.$) {
|
|
175
|
+
this.$ = {};
|
|
176
|
+
}
|
|
177
|
+
|
|
173
178
|
this.shadowRoot.querySelectorAll('[id]').forEach((node) => {
|
|
174
179
|
this.$[node.id] = node;
|
|
175
180
|
});
|
package/src/resize-mixin.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2021 -
|
|
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';
|
package/src/resize-mixin.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2021 -
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
}
|
package/src/slot-controller.d.ts
CHANGED
package/src/slot-controller.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2021 -
|
|
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(
|
|
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 =
|
|
45
|
+
this.defaultId = this.constructor.generateId(host, slotName);
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
|
package/src/tabindex-mixin.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2021 -
|
|
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';
|
package/src/tabindex-mixin.js
CHANGED
package/src/templates.js
CHANGED
package/src/unique-id-utils.d.ts
CHANGED