Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

[WEEX-183][jsfm] support append tree on root element #954

Merged
merged 1 commit into from
Dec 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions html5/runtime/vdom/operation.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,9 @@ export function appendBody (doc, node, before) {

function sendBody (doc, node) {
const body = node.toJSON()
const children = body.children
delete body.children
let result = doc.taskCenter.send('dom', { action: 'createBody' }, [body])
if (children) {
children.forEach(child => {
result = doc.taskCenter.send('dom', { action: 'addElement' }, [body.ref, child, -1])
})
if (doc && doc.taskCenter && typeof doc.taskCenter.send === 'function') {
doc.taskCenter.send('dom', { action: 'createBody' }, [body])
}
return result
}

/**
Expand Down
20 changes: 8 additions & 12 deletions html5/test/unit/default/vm/vm.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,20 +245,16 @@ describe('generate virtual dom for a single vm', () => {
attr: {
append: 'tree'
},
children: [{
ref: spy.firstCall.args[2].children[0].ref,
type: 'text',
attr: {
value: '<some text content>'
},
style: {}
}],
style: {}
})
expect(spy.secondCall.args[0]).to.be.equal('test')
expect(spy.secondCall.args[1]).to.be.equal('addElement')
expect(spy.secondCall.args[2]).to.be.equal('_root')
expect(spy.secondCall.args[3]).to.deep.equal({
ref: spy.secondCall.args[3].ref,
type: 'text',
attr: {
value: '<some text content>'
},
style: {}
})
expect(spy.secondCall.args[4]).to.be.equal(-1)

expect(vm._app).equal(app)
const el = doc.body
Expand Down