BarefootJS
view release on metacpan or search on metacpan
lib/BarefootJS.pm view on Meta::CPAN
$host_segment = "|h=$host|m=" . ($mount // '');
}
my $props_json = '';
if ($self->_props && %{$self->_props}) {
$props_json = '|' . $self->backend->encode_json($self->_props);
}
return "<!--bf-scope:$scope_id$host_segment$props_json-->";
}
# Paired end marker for scope_comment above. Bounds the scope's sibling
# range so client-side queries from a fragment-rooted scope don't leak
# onto later siblings owned by the parent (#2289). No `|h=`/`|m=`/props
# segments â the client only needs the scope id to find the matching end.
sub scope_comment_end ($self) {
my $scope_id = $self->_scope_id // '';
return "<!--bf-/scope:$scope_id-->";
}
# ---------------------------------------------------------------------------
# Script Registration
# ---------------------------------------------------------------------------
t/scope_comment.t view on Meta::CPAN
use strict;
use warnings;
use utf8;
use Test2::V0;
use lib 'lib';
use BarefootJS;
# scope_comment / scope_comment_end (#2289): the end marker bounds the
# fragment scope's sibling range on the wire, so client-side queries from
# the scope don't leak onto later siblings owned by the parent. This pins
# the paired-marker contract directly against BarefootJS.pm, independent
# of any adapter's template output.
# A do-nothing backend: scope_comment only touches the backend to
# JSON-encode `_props` (and only when props are set); scope_comment_end
# never touches it at all.
{
package StubBackend;
sub new { bless {}, shift }
( run in 0.638 second using v1.01-cache-2.11-cpan-364913b4093 )