Skip to content

Commit bbd59b9

Browse files
committed
Document children() child indexes
1 parent 1513937 commit bbd59b9

5 files changed

Lines changed: 11 additions & 2 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ Two bundles are used by the benchmark harness and conformance runner:
110110
- eager child views off (child views are built lazily if `children()` is called)
111111
- drop whitespace-only text nodes during parse
112112

113+
`children()` returns a borrowed `[]const u32` index slice into the document's node array.
114+
113115
## Selector Support (v1)
114116

115117
Supported (intentionally limited scope):

docs/api-reference.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ Content/attributes:
4646
- `getAttributeValue(name)`
4747
- `innerText(arena_allocator)`
4848
- `innerTextWithOptions(arena_allocator, TextOptions)`
49+
- `children()` returns borrowed `[]const u32` child indexes
4950

5051
Scoped query entrypoints:
5152

docs/architecture.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@
2626

2727
- Parser is permissive and attempts recovery for malformed markup.
2828
- Raw-text elements and optional-close behavior use table/tag-aware logic.
29-
- Parse options can defer attribute parsing and child-view materialization when needed.
29+
- Parse options currently tune child-view eagerness and whitespace-only text-node dropping.

examples/navigation_and_children.zig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ fn run() !void {
1919

2020
const children = main.children();
2121
try std.testing.expectEqual(@as(usize, 3), children.len);
22+
const first_idx = children[0];
23+
const first_via_index = main.doc.nodeAt(first_idx) orelse return error.TestUnexpectedResult;
24+
try std.testing.expectEqualStrings("title", first_via_index.getAttributeValue("id").?);
2225
}
2326

2427
test "navigation and borrowed children slice" {

src/examples_tests.zig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@ test "example parity: navigation and children" {
6363

6464
try std.testing.expectEqualStrings("title", first.getAttributeValue("id").?);
6565
try std.testing.expectEqualStrings("body", last.getAttributeValue("id").?);
66-
try std.testing.expectEqual(@as(usize, 3), main.children().len);
66+
const children = main.children();
67+
try std.testing.expectEqual(@as(usize, 3), children.len);
68+
const first_via_index = main.doc.nodeAt(children[0]) orelse return error.TestUnexpectedResult;
69+
try std.testing.expectEqualStrings("title", first_via_index.getAttributeValue("id").?);
6770
}
6871

6972
test "example parity: innerText options" {

0 commit comments

Comments
 (0)