Skip to content

Commit d2a68e6

Browse files
committed
cdp: add attributes to the node's writer
1 parent 09fbbc1 commit d2a68e6

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/cdp/Node.zig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,19 @@ pub const Writer = struct {
260260
try w.write(parent_node.id);
261261
}
262262

263+
const _map = try parser.nodeGetAttributes(n);
264+
if (_map) |map| {
265+
const attr_count = try parser.namedNodeMapGetLength(map);
266+
try w.objectField("attributes");
267+
try w.beginArray();
268+
for (0..attr_count) |i| {
269+
const attr = try parser.namedNodeMapItem(map, @intCast(i)) orelse continue;
270+
try w.write(try parser.attributeGetName(attr));
271+
try w.write(try parser.attributeGetValue(attr) orelse continue);
272+
}
273+
try w.endArray();
274+
}
275+
263276
try w.objectField("nodeType");
264277
try w.write(@intFromEnum(try parser.nodeType(n)));
265278

0 commit comments

Comments
 (0)