Revert "Revert "More performance improvements + etc.""
This commit is contained in:
parent
897060d6ed
commit
b2faa43f91
28 changed files with 3207 additions and 1326 deletions
|
|
@ -5,8 +5,9 @@
|
|||
|
||||
<!-- Dependencies -->
|
||||
<script src="../node_modules/chai/chai.js"></script>
|
||||
<script src="../node_modules/sinon/pkg/sinon.js" charset="utf-8"></script>
|
||||
<script src="../node_modules/sinon-chai/lib/sinon-chai.js" charset="utf-8"></script>
|
||||
<script src="../node_modules/chai-string/chai-string.js"></script>
|
||||
<script src="../node_modules/sinon/pkg/sinon.js"></script>
|
||||
<script src="../node_modules/sinon-chai/lib/sinon-chai.js"></script>
|
||||
<link rel="stylesheet" href="../node_modules/mocha/mocha.css">
|
||||
<script src="../node_modules/mocha/mocha.js"></script>
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,21 @@ describe("m()", function () {
|
|||
expect(m).to.be.a("function")
|
||||
})
|
||||
|
||||
it("throws with an empty tag name", function () {
|
||||
expect(function () {
|
||||
m("")
|
||||
}).to.throw(TypeError)
|
||||
})
|
||||
|
||||
it("throws when the tag is not a string or object", function () {
|
||||
expect(function () { m(0) }).to.throw(TypeError)
|
||||
expect(function () { m(1) }).to.throw(TypeError)
|
||||
expect(function () { m(true) }).to.throw(TypeError)
|
||||
expect(function () { m(null) }).to.throw(TypeError)
|
||||
expect(function () { m(undefined) }).to.throw(TypeError)
|
||||
expect(function () { m([]) }).to.throw(TypeError)
|
||||
})
|
||||
|
||||
it("sets correct tag name", function () {
|
||||
expect(m("div")).to.have.property("tag", "div")
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1315,30 +1315,31 @@ describe("m.render()", function () {
|
|||
expect(before).to.equal(after)
|
||||
})
|
||||
|
||||
// FIXME: implement document.createRange().createContextualFragment() in the
|
||||
// mock document to fix this test
|
||||
it("keeps unkeyed identity if mixed with elements/trusted text and identity can be inferred", function () { // eslint-disable-line
|
||||
var root = mock.document.createElement("div")
|
||||
// FIXME: implement document.createRange().createContextualFragment()
|
||||
dom(function () {
|
||||
it("keeps unkeyed identity if mixed with elements/trusted text and identity can be inferred", function () { // eslint-disable-line
|
||||
var root = document.createElement("div")
|
||||
|
||||
m.render(root, m("div", [
|
||||
m("a", {key: 1}),
|
||||
m("a", {key: 2}),
|
||||
m.trust("a"),
|
||||
m("a", {key: 3}),
|
||||
m("i")
|
||||
]))
|
||||
var before = root.childNodes[0].childNodes[4]
|
||||
m.render(root, m("div", [
|
||||
m("a", {key: 1}),
|
||||
m("a", {key: 2}),
|
||||
m.trust("a"),
|
||||
m("a", {key: 3}),
|
||||
m("i")
|
||||
]))
|
||||
var before = root.childNodes[0].childNodes[4]
|
||||
|
||||
m.render(root, m("div", [
|
||||
m("a", {key: 3}),
|
||||
m("a", {key: 4}),
|
||||
m.trust("a"),
|
||||
m("i"),
|
||||
m("a", {key: 1})
|
||||
]))
|
||||
var after = root.childNodes[0].childNodes[3]
|
||||
m.render(root, m("div", [
|
||||
m("a", {key: 3}),
|
||||
m("a", {key: 4}),
|
||||
m.trust("a"),
|
||||
m("i"),
|
||||
m("a", {key: 1})
|
||||
]))
|
||||
var after = root.childNodes[0].childNodes[3]
|
||||
|
||||
expect(before).to.equal(after)
|
||||
expect(before).to.equal(after)
|
||||
})
|
||||
})
|
||||
|
||||
it("uses the syntax class if it's given as `undefined` in attr", function () { // eslint-disable-line
|
||||
|
|
@ -1411,6 +1412,7 @@ describe("m.render()", function () {
|
|||
|
||||
// https://github.com/lhorie/mithril.js/issues/214
|
||||
it("keeps all input events", function () {
|
||||
this.timeout(3000) // eslint-disable-line no-invalid-this
|
||||
var root = mock.document.createElement("div")
|
||||
|
||||
var ctrl = m.mount(root, {
|
||||
|
|
|
|||
|
|
@ -29,7 +29,9 @@ describe("m.trust()", function () {
|
|||
it("works with mixed trusted content in div", function () {
|
||||
var root = document.createElement("div")
|
||||
m.render(root, [m.trust("<p>1</p><p>2</p>"), m("i", "foo")])
|
||||
expect(root.childNodes[2].tagName).to.equal("I")
|
||||
// Case-insensitive test to work around weird heisenbug with the
|
||||
// browser
|
||||
expect(root.childNodes[2].tagName).to.equalIgnoreCase("I")
|
||||
})
|
||||
|
||||
it("works with mixed trusted content in text nodes", function () {
|
||||
|
|
@ -38,7 +40,9 @@ describe("m.trust()", function () {
|
|||
m.trust("<p>1</p>123<p>2</p>"),
|
||||
m("i", "foo")
|
||||
])
|
||||
expect(root.childNodes[3].tagName).to.equal("I")
|
||||
// Case-insensitive test to work around weird heisenbug with the
|
||||
// browser
|
||||
expect(root.childNodes[3].tagName).to.equalIgnoreCase("I")
|
||||
})
|
||||
|
||||
// FIXME: this is a bug (trusted string's contents rendered as just
|
||||
|
|
@ -52,7 +56,9 @@ describe("m.trust()", function () {
|
|||
m("td", "foo")
|
||||
])
|
||||
|
||||
expect(root.childNodes[2].tagName).to.equal("TD")
|
||||
// Case-insensitive test to work around weird heisenbug with the
|
||||
// browser
|
||||
expect(root.childNodes[2].tagName).to.equalIgnoreCase("TD")
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue