Merge pull request #700 from trheyi/main

fix missing trans-text attribute bug
This commit is contained in:
Max 2024-07-21 07:21:32 +08:00 committed by GitHub
commit 4872ced2de
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -271,6 +271,20 @@ func (page *Page) copyChildren(from *goquery.Selection, to *goquery.Selection) e
return nil
}
children.Find("slot").Remove()
// copy trans-node and trans-text properties
transNode, hasTransNode := from.Attr("s:trans-node")
transText, hasTransText := from.Attr("s:trans-text")
if hasTransNode || hasTransText {
parent := to.Find("children").Parent()
if hasTransNode {
parent.SetAttr("s:trans-node", transNode)
}
if hasTransText {
parent.SetAttr("s:trans-text", transText)
}
}
to.Find("children").ReplaceWithSelection(children)
return nil
}