Create XmlFragment clone / copy

Hello .So I want to make a copy of an existing XmlFragment .Lets say I have fragment1 and fragment2
,fragment1 is the one with the data .I want fragment2 to be a copy of fragment1.

`
fragment1 = ydoc.getXmlFragment(‘fragment1’)
fragment2 = ydoc.getXmlFragment(‘fragment2’)

fragment1.toArray().forEach((el,i)=>{
fragment2.insert(i,el) // or fragment2.push(el)
})
`

When I try this I’m getting the fallowing error :
TypeError: content.forEach is not a function
at typeListInsertGenericsAfter (yjs.mjs:4860)
at typeListInsertGenerics (yjs.mjs:4913)
at yjs.mjs:7095
at transact (yjs.mjs:3198)
at YXmlFragment.insert (yjs.mjs:7094)

Solved it. Saw the code of the clone() function and this worked :

fragment2.insert(0,fragment1.toArray().map(item=>item instanceof AbstractType ? item.clone() : item));