go-html/translator_clone_js.go
Virgil 7cbf678738
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
fix(html): clone mutable translators in context copies
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-04 01:23:40 +00:00

24 lines
416 B
Go

//go:build js
// SPDX-Licence-Identifier: EUPL-1.2
package html
func cloneTranslator(svc Translator, _ string) Translator {
if svc == nil {
return nil
}
if cloner, ok := svc.(translatorCloner); ok && cloner != nil {
if clone := cloner.Clone(); clone != nil {
return clone
}
}
if current, ok := svc.(*defaultTranslator); ok && current != nil {
clone := *current
return &clone
}
return svc
}