@hyperframes/core 0.8.223 → 0.8.224

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.
@@ -34,7 +34,25 @@ function normalizeAuthoredRootIdSelector(selector, authoredRootId) {
34
34
  function compositionBoxSelector(scope) {
35
35
  return `${scope}:not(:has([${INNER_ROOT_ATTR}])), ${scope} > [${INNER_ROOT_ATTR}]`;
36
36
  }
37
+ function dropRootCompositionIdAttr(selector, authoredRootId, compositionId) {
38
+ const trimmed = authoredRootId?.trim();
39
+ if (!trimmed)
40
+ return selector;
41
+ const authored = escapeRegExp(`[${AUTHORED_ROOT_ID_ATTR}="${escapeCssAttributeValue(trimmed)}"]`);
42
+ const quotedCompId = escapeRegExp(compositionId);
43
+ const comp = String.raw `\[\s*data-composition-id\s*=\s*(?:"${quotedCompId}"|'${quotedCompId}')\s*\]`;
44
+ return selector.replace(new RegExp(`(${authored})${comp}|${comp}(${authored})`, "g"), "$1$2");
45
+ }
37
46
  function scopeSelector(selector, scope, compositionId, authoredRootId, compoundAuthoredRoot, scopeRootSelectors) {
47
+ const authored = normalizeAuthoredRootIdSelector(selector, authoredRootId);
48
+ const wrapperAlone = dropRootCompositionIdAttr(authored, authoredRootId, compositionId);
49
+ const scopeOnce = (text) => scopeSelectorOnce(text, scope, compositionId, authoredRootId, compoundAuthoredRoot, scopeRootSelectors);
50
+ if (wrapperAlone === authored)
51
+ return scopeOnce(selector);
52
+ // A named host carries the id, the preserved inner root the authored id; an anonymous host's wrapper carries both.
53
+ return `${scopeOnce(authored).trim()}, ${scopeOnce(wrapperAlone).trim()}`;
54
+ }
55
+ function scopeSelectorOnce(selector, scope, compositionId, authoredRootId, compoundAuthoredRoot, scopeRootSelectors) {
38
56
  const selectorWithoutAuthoredRootId = normalizeAuthoredRootIdSelector(selector, authoredRootId);
39
57
  const selectorWithoutRootTiming = normalizeCompositionRootSelector(selectorWithoutAuthoredRootId, scope, compositionId);
40
58
  const trimmed = selectorWithoutRootTiming.trim();