Skip to content

Commit

Permalink
* [jsfm] fixed & closed #1148
Browse files Browse the repository at this point in the history
  • Loading branch information
Jinjiang committed Sep 8, 2016
1 parent c5aeb46 commit 4209850
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 0 deletions.
46 changes: 46 additions & 0 deletions html5/test/unit/default/assets/append-root-event.input
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// module
define('@weex-component/append-root-event', function(require, exports, module) {

;
module.exports = {
data: function() {
return {
x: 1
}
},
methods: {
update: function() {
this.x = 2
}
}
}


;
module.exports.style = {}

;
module.exports.template = {
"type": "div",
"append": "tree",
"children": [{
"type": "text",
"events": {
"click": "update"
},
"attr": {
"value": function() {
return this.x
}
}
}]
}

;
})

// require module

bootstrap('@weex-component/append-root-event', {
"transformerVersion": "0.3.1"
})
13 changes: 13 additions & 0 deletions html5/test/unit/default/assets/append-root-event.output
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
type: 'div',
attr: {
append: "tree"
},
children: [{
type: 'text',
event: ['click'],
attr: {
value: 1
}
}]
}
23 changes: 23 additions & 0 deletions html5/test/unit/default/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,29 @@ describe('test input and output', () => {
delete allDocs[name]
})

it('append-root-event case', () => {
const name = 'append-root-event'
const inputCode = readInput(name)
const outputCode = readOutput(name)
const doc = new Document(name)
allDocs[name] = doc

framework.createInstance(name, inputCode)
const expected = eval('(' + outputCode + ')')
const actual = doc.toJSON()
expect(actual).eql(expected)

framework.callJS(name, [{
method: 'fireEvent',
args: [doc.body.children[0].ref, 'click', {}]
}])

expect(doc.body.children[0].attr.value).eql(2)

framework.destroyInstance(name)
delete allDocs[name]
})

it('if case', () => {
const name = 'if'
const inputCode = readInput(name)
Expand Down
1 change: 1 addition & 0 deletions html5/vdom/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ function appendBody (doc, node, before) {
node.docId = doc.id
node.ownerDocument = doc
node.parentNode = documentElement
linkParent(node, documentElement)
}
else {
node.children.forEach(child => {
Expand Down

0 comments on commit 4209850

Please sign in to comment.