test: fix component with missing allocator

This commit is contained in:
Nurul Huda (Apon) 2026-06-13 00:30:59 +06:00
parent 1b80e4cd3f
commit 950dfa7aab
No known key found for this signature in database
GPG Key ID: 5D3F1DE2855A2F79
5 changed files with 7 additions and 4 deletions

View File

@ -35,10 +35,11 @@ pub fn Page(allocator: zx.Allocator) zx.Component {
const InputProps = struct { value: []const u8, name: []const u8, extra: []const u8 = "" };
fn Input(ctx: *zx.ComponentCtx(InputProps)) zx.Component {
var _zx = @import("zx").x.init();
var _zx = @import("zx").x.allocInit(ctx.allocator);
return _zx.ele(
.div,
.{
.allocator = ctx.allocator,
.children = &.{
_zx.ele(
.label,

View File

@ -20,7 +20,7 @@ pub fn Page(allocator: zx.Allocator) zx.Component {
const InputProps = struct { value: []const u8, name: []const u8, extra: []const u8 = "" };
fn Input(ctx: *zx.ComponentCtx(InputProps)) zx.Component {
return (
<div>
<div @allocator={ctx.allocator}>
<label>{ctx.props.name}</label>
<input type="text" {..ctx.props} />
<input extra="override-by-spr" {..ctx.props} />

View File

@ -1,4 +1,5 @@
pub const components = [_]zx.client.ComponentMeta{
.{
.type = .client,
.id = "c8fee6a",

View File

@ -44,10 +44,11 @@ fn Component(ctx: *zx.ComponentCtx(struct {
text: []const u8,
name: []const u8,
})) zx.Component {
var _zx = @import("zx").x.init();
var _zx = @import("zx").x.allocInit(ctx.allocator);
return _zx.ele(
.div,
.{
.allocator = ctx.allocator,
.children = &.{
_zx.ele(
.p,

View File

@ -15,7 +15,7 @@ fn Component(ctx: *zx.ComponentCtx(struct {
name: []const u8,
})) zx.Component {
return (
<div>
<div @allocator={ctx.allocator}>
<p>{ctx.props.text}</p>
<p>{ctx.props.name}</p>
</div>