mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-02-04 06:23:45 +00:00
Add 'clone' callback to build, implement for Input
This commit is contained in:
@@ -978,6 +978,11 @@ pub fn cloneElement(self: *Element, deep: bool, page: *Page) !*Node {
|
|||||||
|
|
||||||
const node = try page.createElement(namespace_uri, tag_name, self._attributes);
|
const node = try page.createElement(namespace_uri, tag_name, self._attributes);
|
||||||
|
|
||||||
|
// Allow element-specific types to copy their runtime state
|
||||||
|
_ = Element.Build.call(node.as(Element), "cloned", .{ self, node.as(Element), page }) catch |err| {
|
||||||
|
log.err(.dom, "element.clone.failed", .{ .err = err });
|
||||||
|
};
|
||||||
|
|
||||||
if (deep) {
|
if (deep) {
|
||||||
var child_it = self.asNode().childrenIterator();
|
var child_it = self.asNode().childrenIterator();
|
||||||
while (child_it.next()) |child| {
|
while (child_it.next()) |child| {
|
||||||
|
|||||||
@@ -404,6 +404,17 @@ pub const Build = struct {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn cloned(source_element: *Element, cloned_element: *Element, _: *Page) !void {
|
||||||
|
const source = source_element.as(Input);
|
||||||
|
const clone = cloned_element.as(Input);
|
||||||
|
|
||||||
|
// Copy runtime state from source to clone
|
||||||
|
clone._value = source._value;
|
||||||
|
clone._checked = source._checked;
|
||||||
|
clone._checked_dirty = source._checked_dirty;
|
||||||
|
clone._selected = source._selected;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const testing = @import("../../../../testing.zig");
|
const testing = @import("../../../../testing.zig");
|
||||||
|
|||||||
Reference in New Issue
Block a user