@descope-ui/common 3.13.3 → 3.14.1

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": "@descope-ui/common",
3
- "version": "3.13.3",
3
+ "version": "3.14.1",
4
4
  "files": [
5
5
  "src"
6
6
  ],
@@ -113,7 +113,7 @@ export const injectStyle = (cssString, ref, { prepend = false } = {}) => {
113
113
  let style;
114
114
 
115
115
  try {
116
- // eslint-disable-next-line no-undef
116
+
117
117
  style = new CSSStyleSheet();
118
118
  } catch {
119
119
  // fallback for browsers that don't support CSSStyleSheet
@@ -178,3 +178,18 @@ export const limitAbbreviation = (str, limit = 2) =>
178
178
  .splice(0, limit)
179
179
  .map((s) => s[0]?.toUpperCase())
180
180
  .join('');
181
+
182
+ export const cloneSlottedNodes = (element, slotName) => {
183
+ if (!element || !slotName) return null;
184
+ const sources = element.querySelectorAll(`:scope > [slot="${slotName}"]`);
185
+ if (!sources.length) return null;
186
+ const fragment = document.createDocumentFragment();
187
+ sources.forEach((source) => {
188
+ const clone = source.content
189
+ ? source.content.cloneNode(true)
190
+ : source.cloneNode(true);
191
+ if (clone.removeAttribute) clone.removeAttribute('slot');
192
+ fragment.append(clone);
193
+ });
194
+ return fragment;
195
+ };
@@ -26,11 +26,11 @@ export const isFunction = (maybeFunc) => typeof maybeFunc === 'function';
26
26
 
27
27
  export const isUrl = (maybeUrl) => {
28
28
  try {
29
- // eslint-disable-next-line no-new
29
+ // eslint-disable-next-line no-undef
30
30
  new URL(maybeUrl);
31
31
 
32
32
  return true;
33
- } catch (e) {
33
+ } catch {
34
34
  return false;
35
35
  }
36
36
  };