@vaadin/component-base
Advanced tools
Comparing version 24.4.0-alpha13 to 24.4.0-alpha14
{ | ||
"name": "@vaadin/component-base", | ||
"version": "24.4.0-alpha13", | ||
"version": "24.4.0-alpha14", | ||
"publishConfig": { | ||
@@ -45,3 +45,3 @@ "access": "public" | ||
}, | ||
"gitHead": "97246b0703cd04a4b0ea5dcd49e2581d45cf6367" | ||
"gitHead": "303c07338b748bc6036a92a92cf1733c3bc351eb" | ||
} |
@@ -12,3 +12,3 @@ /** | ||
get() { | ||
return '24.4.0-alpha13'; | ||
return '24.4.0-alpha14'; | ||
}, | ||
@@ -15,0 +15,0 @@ }); |
@@ -8,5 +8,9 @@ /** | ||
/** | ||
* Check if two paths can be resolved as URLs | ||
* with the same origin and pathname. | ||
* Checks if two paths match based on their origin, pathname, and query parameters. | ||
* | ||
* The function matches an actual URL against an expected URL to see if they share | ||
* the same base origin (like https://example.com), the same path (like /path/to/page), | ||
* and if the actual URL contains at least all the query parameters with the same values | ||
* from the expected URL. | ||
*/ | ||
export declare function matchPaths(path1: string, path2: string): boolean; | ||
export declare function matchPaths(actual: string, expected: string): boolean; |
@@ -8,13 +8,35 @@ /** | ||
/** | ||
* Check if two paths can be resolved as URLs | ||
* with the same origin and pathname. | ||
* Checks if one set of URL parameters contains all the parameters | ||
* with the same values from another set. | ||
* | ||
* @param {string} path1 | ||
* @param {string} path2 | ||
* @param {URLSearchParams} actual | ||
* @param {URLSearchParams} expected | ||
*/ | ||
export function matchPaths(path1, path2) { | ||
function containsQueryParams(actual, expected) { | ||
return [...expected.entries()].every(([key, value]) => { | ||
return actual.getAll(key).includes(value); | ||
}); | ||
} | ||
/** | ||
* Checks if two paths match based on their origin, pathname, and query parameters. | ||
* | ||
* The function matches an actual URL against an expected URL to see if they share | ||
* the same base origin (like https://example.com), the same path (like /path/to/page), | ||
* and if the actual URL contains at least all the query parameters with the same values | ||
* from the expected URL. | ||
* | ||
* @param {string} actual The actual URL to match. | ||
* @param {string} expected The expected URL to match. | ||
*/ | ||
export function matchPaths(actual, expected) { | ||
const base = document.baseURI; | ||
const url1 = new URL(path1, base); | ||
const url2 = new URL(path2, base); | ||
return url1.origin === url2.origin && url1.pathname === url2.pathname; | ||
const actualUrl = new URL(actual, base); | ||
const expectedUrl = new URL(expected, base); | ||
return ( | ||
actualUrl.origin === expectedUrl.origin && | ||
actualUrl.pathname === expectedUrl.pathname && | ||
containsQueryParams(actualUrl.searchParams, expectedUrl.searchParams) | ||
); | ||
} |
@@ -237,2 +237,3 @@ /** | ||
el.style.paddingTop = ''; | ||
el.style.opacity = ''; | ||
el.__virtualizerPlaceholder = false; | ||
@@ -262,2 +263,3 @@ } | ||
el.style.paddingTop = `${this.__placeholderHeight}px`; | ||
el.style.opacity = '0'; | ||
el.__virtualizerPlaceholder = true; | ||
@@ -264,0 +266,0 @@ |
213652
6337