Skip to content

Commit

Permalink
Add test to ensure nested existing node onloads fire correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
shama committed Jul 6, 2016
1 parent 196d20e commit 82d9652
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@
"dependencies": {
"global": "^4.3.0",
"hyperx": "^2.0.2",
"on-load": "^3.0.0"
"on-load": "^3.1.1"
},
"devDependencies": {
"browser-process-hrtime": "^0.1.2",
"browserify": "^13.0.0",
"electron-prebuilt": "^0.36.9",
"morphdom": "^1.4.5",
"standard": "^6.0.7",
"tape": "^4.6.0",
"testron": "^1.2.0",
Expand Down
29 changes: 29 additions & 0 deletions test/onload.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var test = require('tape')
var bel = require('../')
var document = require('global/document')
var morphdom = require('morphdom')

test('fire onload and unload events', function (t) {
t.plan(2)
Expand All @@ -16,3 +17,31 @@ test('fire onload and unload events', function (t) {
document.body.appendChild(result)
document.body.removeChild(result)
})

test('onload with nested existing elements', function (t) {
t.plan(3)
function render1 () {
return bel`<ul onload=${function () {
t.ok(true, 'parent fired onload')
}}><li>hi</li></ul>`
}
function render2 () {
return bel`<ul><li onload=${function (el) {
t.ok(true, 'nested fired onload')
}} onunload=${function (el) {
t.ok(true, 'nested fired onunload')
t.end()
}}>hi</li></ul>`
}
function render3 () {
return bel`<ul><li>hi</li></ul>`
}
var root = render1()
document.body.appendChild(root)
setTimeout(function () {
morphdom(root, render2())
setTimeout(function () {
morphdom(root, render3())
}, 10)
}, 10)
})

0 comments on commit 82d9652

Please sign in to comment.