本文整理匯總了TypeScript中@bokehjs/document.Document.roots方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Document.roots方法的具體用法?TypeScript Document.roots怎麽用?TypeScript Document.roots使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@bokehjs/document.Document
的用法示例。
在下文中一共展示了Document.roots方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it("sets proper document on models added during patching", () => {
const d = new Document()
expect(d.roots().length).to.equal(0)
expect(Object.keys(d._all_models).length).to.equal(0)
const root1 = new SomeModel({ foo: 42 })
const child1 = new SomeModel({ foo: 44 })
d.add_root(root1)
expect(d.roots().length).to.equal(1)
// can't create copy of doc here like other test. Testing explicitly that
// doc attach happens when *not* creating a new document (i.e only patching)
// Testing only for/against null .document is not the strongest test but it
// should suffice.
expect(root1.document!.roots().length).equal(1)
expect(root1.child).to.equal(null)
const event1 = new ev.ModelChangedEvent(d, root1, 'child', root1.child, child1)
const patch1 = d.create_json_patch_string([event1])
d.apply_json_patch(JSON.parse(patch1))
expect(root1.document!.roots().length).equal(1)
expect(root1.child!.document!.roots().length).equal(1)
})