implement prev/nextSibling&firstChild & parent - #259

This commit is contained in:
Kevin Jahns
2020-11-14 13:33:43 +01:00
parent 0aca7bbefa
commit 1ed58909d3
6 changed files with 83 additions and 2 deletions

View File

@@ -87,3 +87,19 @@ export const testYtextAttributes = tc => {
t.compare(ytext.getAttribute('test'), 42)
t.compare(ytext.getAttributes(), { test: 42 })
}
/**
* @param {t.TestCase} tc
*/
export const testSiblings = tc => {
const ydoc = new Y.Doc()
const yxml = ydoc.getXmlFragment()
const first = new Y.XmlText()
const second = new Y.XmlElement('p')
yxml.insert(0, [first, second])
t.assert(first.nextSibling === second)
t.assert(second.prevSibling === first)
t.assert(first.parent === yxml)
t.assert(yxml.parent === null)
t.assert(yxml.firstChild === first)
}