@vaadin/component-base 24.5.0-alpha9 → 24.5.0-rc1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/component-base",
3
- "version": "24.5.0-alpha9",
3
+ "version": "24.5.0-rc1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -38,9 +38,9 @@
38
38
  "lit": "^3.0.0"
39
39
  },
40
40
  "devDependencies": {
41
- "@vaadin/chai-plugins": "24.5.0-alpha9",
41
+ "@vaadin/chai-plugins": "24.5.0-rc1",
42
42
  "@vaadin/testing-helpers": "^1.0.0",
43
43
  "sinon": "^18.0.0"
44
44
  },
45
- "gitHead": "804744762f3bec0a2247c4bbcbbb204dbcd78bc0"
45
+ "gitHead": "a8ae853ab69d7938cf507843784f1551a2eeb972"
46
46
  }
package/src/define.d.ts CHANGED
@@ -7,4 +7,4 @@ export interface CustomElementType extends CustomElementConstructor {
7
7
  is: string;
8
8
  }
9
9
 
10
- export declare function defineCustomElement(CustomElement: CustomElementConstructor): void;
10
+ export declare function defineCustomElement(CustomElement: CustomElementConstructor, version?: string): void;
package/src/define.js CHANGED
@@ -4,15 +4,15 @@
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
 
7
- export function defineCustomElement(CustomElement) {
7
+ export function defineCustomElement(CustomElement, version = '24.5.0-rc1') {
8
+ Object.defineProperty(CustomElement, 'version', {
9
+ get() {
10
+ return version;
11
+ },
12
+ });
13
+
8
14
  const defined = customElements.get(CustomElement.is);
9
15
  if (!defined) {
10
- Object.defineProperty(CustomElement, 'version', {
11
- get() {
12
- return '24.5.0-alpha9';
13
- },
14
- });
15
-
16
16
  customElements.define(CustomElement.is, CustomElement);
17
17
  } else {
18
18
  const definedVersion = defined.version;
@@ -19,9 +19,6 @@ export class MediaQueryController implements ReactiveController {
19
19
  */
20
20
  protected callback: (matches: boolean) => void;
21
21
 
22
- /**
23
- * @param {HTMLElement} host
24
- */
25
22
  constructor(query: string, callback: (matches: boolean) => void);
26
23
 
27
24
  hostConnected(): void;
package/src/url-utils.js CHANGED
@@ -27,15 +27,17 @@ function containsQueryParams(actual, expected) {
27
27
  *
28
28
  * @param {string} actual The actual URL to match.
29
29
  * @param {string} expected The expected URL to match.
30
+ * @param {Object} matchOptions Options for path matching.
30
31
  */
31
- export function matchPaths(actual, expected) {
32
+ export function matchPaths(actual, expected, matchOptions = { matchNested: false }) {
32
33
  const base = document.baseURI;
33
34
  const actualUrl = new URL(actual, base);
34
35
  const expectedUrl = new URL(expected, base);
35
36
 
36
- return (
37
- actualUrl.origin === expectedUrl.origin &&
38
- actualUrl.pathname === expectedUrl.pathname &&
39
- containsQueryParams(actualUrl.searchParams, expectedUrl.searchParams)
40
- );
37
+ const matchesOrigin = actualUrl.origin === expectedUrl.origin;
38
+ const matchesPath = matchOptions.matchNested
39
+ ? actualUrl.pathname === expectedUrl.pathname || actualUrl.pathname.startsWith(`${expectedUrl.pathname}/`)
40
+ : actualUrl.pathname === expectedUrl.pathname;
41
+
42
+ return matchesOrigin && matchesPath && containsQueryParams(actualUrl.searchParams, expectedUrl.searchParams);
41
43
  }