@vaadin/component-base 23.1.0 → 23.2.0-dev.53560527d
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/element-mixin.js +1 -1
- package/src/slot-controller.js +2 -9
- package/src/unique-id-utils.d.ts +15 -0
- package/src/unique-id-utils.js +26 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/component-base",
|
|
3
|
-
"version": "23.
|
|
3
|
+
"version": "23.2.0-dev.53560527d",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"@vaadin/testing-helpers": "^0.3.2",
|
|
43
43
|
"sinon": "^13.0.2"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "6c5c18369b09e22e76365d8a8a5e4bbb220f969b"
|
|
46
46
|
}
|
package/src/element-mixin.js
CHANGED
package/src/slot-controller.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
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
|
-
import { dashToCamelCase } from '@polymer/polymer/lib/utils/case-map.js';
|
|
7
6
|
import { FlattenedNodesObserver } from '@polymer/polymer/lib/utils/flattened-nodes-observer.js';
|
|
7
|
+
import { generateUniqueId } from './unique-id-utils.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* A controller for providing content to slot element and observing changes.
|
|
@@ -20,14 +20,7 @@ export class SlotController extends EventTarget {
|
|
|
20
20
|
*/
|
|
21
21
|
static generateId(slotName, host) {
|
|
22
22
|
const prefix = slotName || 'default';
|
|
23
|
-
|
|
24
|
-
// Support dash-case slot names e.g. "error-message"
|
|
25
|
-
const field = `${dashToCamelCase(prefix)}Id`;
|
|
26
|
-
|
|
27
|
-
// Maintain the unique ID counter for a given prefix.
|
|
28
|
-
this[field] = 1 + this[field] || 0;
|
|
29
|
-
|
|
30
|
-
return `${prefix}-${host.localName}-${this[field]}`;
|
|
23
|
+
return `${prefix}-${host.localName}-${generateUniqueId()}`;
|
|
31
24
|
}
|
|
32
25
|
|
|
33
26
|
constructor(host, slotName, slotFactory, slotInitializer) {
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Resets the unique id counter.
|
|
9
|
+
*/
|
|
10
|
+
export function resetUniqueId(): void;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Returns a unique integer id.
|
|
14
|
+
*/
|
|
15
|
+
export function generateUniqueId(): number;
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
|
|
7
|
+
let uniqueId = 0;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Resets the unique id counter.
|
|
11
|
+
*
|
|
12
|
+
* @return {void}
|
|
13
|
+
*/
|
|
14
|
+
export function resetUniqueId() {
|
|
15
|
+
uniqueId = 0;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Returns a unique integer id.
|
|
20
|
+
*
|
|
21
|
+
* @return {number}
|
|
22
|
+
*/
|
|
23
|
+
export function generateUniqueId() {
|
|
24
|
+
// eslint-disable-next-line no-plusplus
|
|
25
|
+
return uniqueId++;
|
|
26
|
+
}
|