\XF\Html\Text::copy instantiates a new \XF\Html\Tag, but it should probably instantiate a new \XF\Html\Text. As it stands, it will return a tag whose name is the same as the current Text's content.
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.2.12).
Change log:
In Text::copy return a Text element rather than Tag.