Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
livoras committed Dec 16, 2015
1 parent 004bbf2 commit 489bf8e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
4 changes: 1 addition & 3 deletions lib/element.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ Element.prototype.render = function () {
_.setAttr(el, propName, propValue)
}

var children = this.children || []

_.each(children, function (child) {
_.each(this.children, function (child) {
var childEl = (child instanceof Element)
? child.render()
: document.createTextNode(child)
Expand Down
22 changes: 22 additions & 0 deletions test/patch.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,4 +228,26 @@ describe('Test patch fucntion', function () {
dom.childNodes[0].value.should.be.equal('new string')
dom.childNodes[1].value.should.be.equal('new string')
})

it('Test nodeValue for IE', function () {
var root = el('div', {}, [
el('input', {value: 'old string'}, null),
el('textarea', {value: 'old string'}, null),
'ok this is a string'
])
var dom = root.render()
var text = dom.childNodes[2]
text.textContent.should.be.equal('ok this is a string')
delete text.textContent

var root2 = el('div', {}, [
el('input', {value: 'old string'}, null),
el('textarea', {value: 'old string'}, null),
'ok this is a string2'
])

var patches = diff(root, root2)
patch(dom, patches)
text.nodeValue.should.be.equal('ok this is a string2')
})
})
8 changes: 8 additions & 0 deletions test/util.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,12 @@ describe('Test utilities', function () {
dom.value.should.be.equal('color')
chai.expect(dom.getAttribute('value')).to.be.null
})

it('Setting dom element\'s attribute: no errors without tagName', function () {
var dom = document.createElement('input')
dom.tagName = void 666
_.setAttr(dom, 'value', 'color')
dom.value.should.be.equal('color')
chai.expect(dom.getAttribute('value')).to.be.null
})
})

0 comments on commit 489bf8e

Please sign in to comment.