BarefootJS

 view release on metacpan or  search on metacpan

lib/BarefootJS.pm  view on Meta::CPAN

}

# ---------------------------------------------------------------------------
# SSR Portal Element Registration (#3119)
# ---------------------------------------------------------------------------

# Collects an `ssrPortalOwnerScope`-flagged element's already-rendered,
# fully-evaluated markup so it can be emitted at the `portals` outlet near
# `</body>` instead of at its source position — the `ref`-callback
# SSR-portal pattern the dialog-style primitives use
# (`DialogOverlay`/`DialogContent`, `DropdownMenuContent`,
# `PopoverContent`, the explicit `<Portal>` component). `$content` already
# carries its own `bf-po` attribute (stamped directly on its own tag by the
# compiler, matching exactly what the client
# `createPortal(el, document.body, { ownerScope })` stamps onto the SAME
# element at hydrate time), so unlike a hypothetical "wrap arbitrary
# children" collector this appends `$content` UNWRAPPED — no extra
# `bf-pi`/`bf-po` container element, which would diverge from what the
# client stamps directly onto the element itself. Returns nothing — every
# call site sinks the return value (a template's `% $bf->register_portal_
# element(...);` statement tag / Kolon `: $bf.register_portal_element(...)

t/manifest_components.t  view on Meta::CPAN


    like dies { $bf->render_child('broken') }, qr/No renderer registered/,
        'template-less row registers nothing';
    is $bf->render_child('toast_title'), '<rendered:ui/toast/ToastTitle>',
        'sibling components still registered';
};

subtest '_snake_case mirrors the Mojo adapter toTemplateName' => sub {
    is BarefootJS::_snake_case('Toast'),         'toast',          'single word';
    is BarefootJS::_snake_case('ToastProvider'), 'toast_provider', 'two words';
    is BarefootJS::_snake_case('DropdownMenu'),  'dropdown_menu',  'kebab-dir module component';
    is BarefootJS::_snake_case('InputOTP'),      'input_o_t_p',    'acronym splits per capital';
};

# `extractSsrDefaults` writes no `value` for a prop without a default
# (spec/js-undefined-value.md, rollout step U1): such an entry seeds JS
# `undefined` (`$BarefootJS::UNDEF`) for an absent or `UNDEF` prop, and its key
# still exists (decision 6). An explicit `value => undef` default is `null`. A
# present prop keeps its value, `undef` (`null`) included.
subtest '_derive_stash_from_defaults seeds undefined for a prop without a default' => sub {
    my $U = $BarefootJS::UNDEF;



( run in 3.012 seconds using v1.01-cache-2.11-cpan-60884a8df76 )