mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 07:03:29 +00:00
set_innerHTML: simpler iteration
This commit is contained in:
@@ -192,11 +192,9 @@ pub const Element = struct {
|
|||||||
// a new fragment
|
// a new fragment
|
||||||
const clean = try parser.documentCreateDocumentFragment(doc);
|
const clean = try parser.documentCreateDocumentFragment(doc);
|
||||||
const children = try parser.nodeGetChildNodes(body);
|
const children = try parser.nodeGetChildNodes(body);
|
||||||
const ln = parser.nodeListLength(children);
|
// always index 0, because nodeAppendChild moves the node out of
|
||||||
for (0..ln) |_| {
|
// the nodeList and into the new tree
|
||||||
// always index 0, because nodeAppendChild moves the node out of
|
while (parser.nodeListItem(children, 0)) |child| {
|
||||||
// the nodeList and into the new tree
|
|
||||||
const child = parser.nodeListItem(children, 0) orelse continue;
|
|
||||||
_ = try parser.nodeAppendChild(@ptrCast(@alignCast(clean)), child);
|
_ = try parser.nodeAppendChild(@ptrCast(@alignCast(clean)), child);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,22 +208,18 @@ pub const Element = struct {
|
|||||||
{
|
{
|
||||||
// First, copy some of the head element
|
// First, copy some of the head element
|
||||||
const children = try parser.nodeGetChildNodes(head);
|
const children = try parser.nodeGetChildNodes(head);
|
||||||
const ln = parser.nodeListLength(children);
|
// always index 0, because nodeAppendChild moves the node out of
|
||||||
for (0..ln) |_| {
|
// the nodeList and into the new tree
|
||||||
// always index 0, because nodeAppendChild moves the node out of
|
while (parser.nodeListItem(children, 0)) |child| {
|
||||||
// the nodeList and into the new tree
|
|
||||||
const child = parser.nodeListItem(children, 0) orelse continue;
|
|
||||||
_ = try parser.nodeAppendChild(node, child);
|
_ = try parser.nodeAppendChild(node, child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const children = try parser.nodeGetChildNodes(body);
|
const children = try parser.nodeGetChildNodes(body);
|
||||||
const ln = parser.nodeListLength(children);
|
// always index 0, because nodeAppendChild moves the node out of
|
||||||
for (0..ln) |_| {
|
// the nodeList and into the new tree
|
||||||
// always index 0, because nodeAppendChild moves the node out of
|
while (parser.nodeListItem(children, 0)) |child| {
|
||||||
// the nodeList and into the new tree
|
|
||||||
const child = parser.nodeListItem(children, 0) orelse continue;
|
|
||||||
_ = try parser.nodeAppendChild(node, child);
|
_ = try parser.nodeAppendChild(node, child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user