Add editorconfig, resolve differences
This includes newlines, tabs, among other things.
This commit is contained in:
parent
80d0a69dab
commit
b4fb21475c
90 changed files with 1707 additions and 1701 deletions
|
|
@ -39,7 +39,7 @@ function hyperscript(selector) {
|
|||
}
|
||||
if (children instanceof Array && children.length == 1 && children[0] != null && children[0].tag === "#") text = children[0].children
|
||||
else childList = children
|
||||
|
||||
|
||||
return Node(tag || "div", attrs.key, hasAttrs ? attrs : undefined, childList, text, undefined)
|
||||
}
|
||||
}
|
||||
|
|
@ -57,9 +57,9 @@ function hyperscript(selector) {
|
|||
children = []
|
||||
for (var i = childrenIndex; i < arguments.length; i++) children.push(arguments[i])
|
||||
}
|
||||
|
||||
|
||||
if (typeof selector === "string") return selectorCache[selector](attrs || {}, Node.normalizeChildren(children))
|
||||
|
||||
|
||||
return Node(selector, attrs && attrs.key, attrs || {}, Node.normalizeChildren(children), undefined, undefined)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,4 +13,4 @@ Node.normalizeChildren = function normalizeChildren(children) {
|
|||
return children
|
||||
}
|
||||
|
||||
module.exports = Node
|
||||
module.exports = Node
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ module.exports = function($window) {
|
|||
|
||||
var onevent
|
||||
function setEventCallback(callback) {return onevent = callback}
|
||||
|
||||
|
||||
//create
|
||||
function createNodes(parent, vnodes, start, end, hooks, nextSibling, ns) {
|
||||
for (var i = start; i < end; i++) {
|
||||
|
|
@ -38,7 +38,7 @@ module.exports = function($window) {
|
|||
var match = vnode.children.match(/^\s*?<(\w+)/im) || []
|
||||
var parent = {caption: "table", thead: "table", tbody: "table", tfoot: "table", tr: "tbody", th: "tr", td: "tr", colgroup: "table", col: "colgroup"}[match[1]] || "div"
|
||||
var temp = $doc.createElement(parent)
|
||||
|
||||
|
||||
temp.innerHTML = vnode.children
|
||||
vnode.dom = temp.firstChild
|
||||
vnode.domSize = temp.childNodes.length
|
||||
|
|
@ -65,24 +65,24 @@ module.exports = function($window) {
|
|||
case "svg": ns = "http://www.w3.org/2000/svg"; break
|
||||
case "math": ns = "http://www.w3.org/1998/Math/MathML"; break
|
||||
}
|
||||
|
||||
|
||||
var attrs = vnode.attrs
|
||||
var is = attrs && attrs.is
|
||||
|
||||
|
||||
var element = ns ?
|
||||
is ? $doc.createElementNS(ns, tag, is) : $doc.createElementNS(ns, tag) :
|
||||
is ? $doc.createElement(tag, is) : $doc.createElement(tag)
|
||||
vnode.dom = element
|
||||
|
||||
|
||||
if (attrs != null) {
|
||||
setAttrs(vnode, attrs, ns)
|
||||
}
|
||||
|
||||
|
||||
if (vnode.text != null) {
|
||||
if (vnode.text !== "") element.textContent = vnode.text
|
||||
else vnode.children = [Node("#", undefined, undefined, vnode.text, undefined, undefined)]
|
||||
}
|
||||
|
||||
|
||||
if (vnode.children != null) {
|
||||
var children = vnode.children
|
||||
createNodes(element, children, 0, children.length, hooks, null, ns)
|
||||
|
|
@ -92,7 +92,7 @@ module.exports = function($window) {
|
|||
}
|
||||
function createComponent(vnode, hooks, ns) {
|
||||
vnode.state = copy(vnode.tag)
|
||||
|
||||
|
||||
initLifecycle(vnode.tag, vnode, hooks)
|
||||
vnode.instance = Node.normalize(vnode.tag.view.call(vnode.state, vnode))
|
||||
if (vnode.instance != null) {
|
||||
|
|
@ -112,7 +112,7 @@ module.exports = function($window) {
|
|||
else {
|
||||
var recycling = isRecyclable(old, vnodes)
|
||||
if (recycling) old = old.concat(old.pool)
|
||||
|
||||
|
||||
var oldStart = 0, start = 0, oldEnd = old.length - 1, end = vnodes.length - 1, map
|
||||
while (oldEnd >= oldStart && end >= start) {
|
||||
var o = old[oldStart], v = vnodes[start]
|
||||
|
|
@ -321,7 +321,7 @@ module.exports = function($window) {
|
|||
}
|
||||
if (expected > 0) return
|
||||
}
|
||||
|
||||
|
||||
onremove(vnode)
|
||||
if (vnode.dom) {
|
||||
var count = vnode.domSize || 1
|
||||
|
|
@ -341,7 +341,7 @@ module.exports = function($window) {
|
|||
function onremove(vnode) {
|
||||
if (vnode.attrs && vnode.attrs.onremove) vnode.attrs.onremove.call(vnode.state, vnode)
|
||||
if (typeof vnode.tag !== "string" && vnode.tag.onremove) vnode.tag.onremove.call(vnode.state, vnode)
|
||||
|
||||
|
||||
var children = vnode.children
|
||||
if (children instanceof Array) {
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
|
|
@ -412,7 +412,7 @@ module.exports = function($window) {
|
|||
function hasIntegrationMethods(source) {
|
||||
return source != null && (source.oncreate || source.onupdate || source.onbeforeremove || source.onremove)
|
||||
}
|
||||
|
||||
|
||||
//style
|
||||
function updateStyle(element, old, style) {
|
||||
if (old === style) element.style = "", old = null
|
||||
|
|
@ -430,7 +430,7 @@ module.exports = function($window) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//event
|
||||
function updateEvent(vnode, key, value) {
|
||||
var element = vnode.dom
|
||||
|
|
@ -470,7 +470,7 @@ module.exports = function($window) {
|
|||
}
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
function copy(data) {
|
||||
if (data instanceof Array) {
|
||||
var output = []
|
||||
|
|
@ -489,7 +489,7 @@ module.exports = function($window) {
|
|||
var hooks = []
|
||||
var active = $doc.activeElement
|
||||
if (dom.vnodes == null) dom.vnodes = []
|
||||
|
||||
|
||||
if (!(vnodes instanceof Array)) vnodes = [vnodes]
|
||||
updateNodes(dom, dom.vnodes, Node.normalizeChildren(vnodes), hooks, null, undefined)
|
||||
for (var i = 0; i < hooks.length; i++) hooks[i]()
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@
|
|||
<script src="test-input.js"></script>
|
||||
<script src="test-textContent.js"></script>
|
||||
<script src="test-component.js"></script>
|
||||
|
||||
|
||||
<script>require("../../ospec/ospec").run()</script>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -15,47 +15,47 @@ o.spec("attributes", function() {
|
|||
o.spec("input readonly", function() {
|
||||
o("when input readonly is true, attribute is present", function() {
|
||||
var a = {tag: "input", attrs: {readonly: true}}
|
||||
|
||||
|
||||
render(root, [a])
|
||||
|
||||
|
||||
o(a.dom.attributes["readonly"].nodeValue).equals("")
|
||||
})
|
||||
o("when input readonly is false, attribute is not present", function() {
|
||||
var a = {tag: "input", attrs: {readonly: false}}
|
||||
|
||||
|
||||
render(root, [a])
|
||||
|
||||
|
||||
o(a.dom.attributes["readonly"]).equals(undefined)
|
||||
})
|
||||
})
|
||||
o.spec("input checked", function() {
|
||||
o("when input checked is true, attribute is not present", function() {
|
||||
var a = {tag: "input", attrs: {checked: true}}
|
||||
|
||||
|
||||
render(root, [a])
|
||||
|
||||
|
||||
o(a.dom.checked).equals(true)
|
||||
o(a.dom.attributes["checked"]).equals(undefined)
|
||||
})
|
||||
o("when input checked is false, attribute is not present", function() {
|
||||
var a = {tag: "input", attrs: {checked: false}}
|
||||
|
||||
|
||||
render(root, [a])
|
||||
|
||||
|
||||
o(a.dom.checked).equals(false)
|
||||
o(a.dom.attributes["checked"]).equals(undefined)
|
||||
})
|
||||
o("after input checked is changed by 3rd party, it can still be changed by render", function() {
|
||||
var a = {tag: "input", attrs: {checked: false}}
|
||||
var b = {tag: "input", attrs: {checked: true}}
|
||||
|
||||
|
||||
render(root, [a])
|
||||
|
||||
|
||||
a.dom.checked = true //setting the javascript property makes the value no longer track the state of the attribute
|
||||
a.dom.checked = false
|
||||
|
||||
|
||||
render(root, [b])
|
||||
|
||||
|
||||
o(a.dom.checked).equals(true)
|
||||
o(a.dom.attributes["checked"]).equals(undefined)
|
||||
})
|
||||
|
|
@ -63,16 +63,16 @@ o.spec("attributes", function() {
|
|||
o.spec("link href", function() {
|
||||
o("when link href is true, attribute is present", function() {
|
||||
var a = {tag: "a", attrs: {href: true}}
|
||||
|
||||
|
||||
render(root, [a])
|
||||
|
||||
|
||||
o(a.dom.attributes["href"]).notEquals(undefined)
|
||||
})
|
||||
o("when link href is false, attribute is not present", function() {
|
||||
var a = {tag: "a", attrs: {href: false}}
|
||||
|
||||
|
||||
render(root, [a])
|
||||
|
||||
|
||||
o(a.dom.attributes["href"]).equals(undefined)
|
||||
})
|
||||
})
|
||||
|
|
@ -85,4 +85,4 @@ o.spec("attributes", function() {
|
|||
o(a.dom.attributes["class"].nodeValue).equals("test")
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -20,9 +20,9 @@ o.spec("component", function() {
|
|||
}
|
||||
}
|
||||
var node = {tag: component}
|
||||
|
||||
|
||||
render(root, [node])
|
||||
|
||||
|
||||
o(root.firstChild.nodeName).equals("DIV")
|
||||
o(root.firstChild.attributes["id"].nodeValue).equals("a")
|
||||
o(root.firstChild.firstChild.nodeValue).equals("b")
|
||||
|
|
@ -34,9 +34,9 @@ o.spec("component", function() {
|
|||
}
|
||||
}
|
||||
var node = {tag: component, attrs: {id: "a"}, text: "b"}
|
||||
|
||||
|
||||
render(root, [node])
|
||||
|
||||
|
||||
o(root.firstChild.nodeName).equals("DIV")
|
||||
o(root.firstChild.attributes["id"].nodeValue).equals("a")
|
||||
o(root.firstChild.firstChild.nodeValue).equals("b")
|
||||
|
|
@ -49,7 +49,7 @@ o.spec("component", function() {
|
|||
}
|
||||
render(root, [{tag: component, attrs: {id: "a"}, text: "b"}])
|
||||
render(root, [{tag: component, attrs: {id: "c"}, text: "d"}])
|
||||
|
||||
|
||||
o(root.firstChild.nodeName).equals("DIV")
|
||||
o(root.firstChild.attributes["id"].nodeValue).equals("c")
|
||||
o(root.firstChild.firstChild.nodeValue).equals("d")
|
||||
|
|
@ -63,7 +63,7 @@ o.spec("component", function() {
|
|||
var div = {tag: "div", key: 2}
|
||||
render(root, [{tag: component, key: 1}, div])
|
||||
render(root, [{tag: "div", key: 2}])
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(1)
|
||||
o(root.firstChild).equals(div.dom)
|
||||
})
|
||||
|
|
@ -74,7 +74,7 @@ o.spec("component", function() {
|
|||
}
|
||||
}
|
||||
render(root, [{tag: "svg", children: [{tag: component}]}])
|
||||
|
||||
|
||||
o(root.firstChild.firstChild.namespaceURI).equals("http://www.w3.org/2000/svg")
|
||||
})
|
||||
o("svg works when updating across component boundary", function() {
|
||||
|
|
@ -85,7 +85,7 @@ o.spec("component", function() {
|
|||
}
|
||||
render(root, [{tag: "svg", children: [{tag: component}]}])
|
||||
render(root, [{tag: "svg", children: [{tag: component}]}])
|
||||
|
||||
|
||||
o(root.firstChild.firstChild.namespaceURI).equals("http://www.w3.org/2000/svg")
|
||||
})
|
||||
})
|
||||
|
|
@ -100,7 +100,7 @@ o.spec("component", function() {
|
|||
}
|
||||
}
|
||||
render(root, [{tag: component}])
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(2)
|
||||
o(root.childNodes[0].nodeName).equals("LABEL")
|
||||
o(root.childNodes[1].nodeName).equals("INPUT")
|
||||
|
|
@ -112,7 +112,7 @@ o.spec("component", function() {
|
|||
}
|
||||
}
|
||||
render(root, [{tag: component}])
|
||||
|
||||
|
||||
o(root.firstChild.nodeType).equals(3)
|
||||
o(root.firstChild.nodeValue).equals("a")
|
||||
})
|
||||
|
|
@ -123,7 +123,7 @@ o.spec("component", function() {
|
|||
}
|
||||
}
|
||||
render(root, [{tag: component}])
|
||||
|
||||
|
||||
o(root.firstChild.nodeType).equals(3)
|
||||
o(root.firstChild.nodeValue).equals("")
|
||||
})
|
||||
|
|
@ -134,7 +134,7 @@ o.spec("component", function() {
|
|||
}
|
||||
}
|
||||
render(root, [{tag: component}])
|
||||
|
||||
|
||||
o(root.firstChild.nodeType).equals(3)
|
||||
o(root.firstChild.nodeValue).equals("1")
|
||||
})
|
||||
|
|
@ -145,7 +145,7 @@ o.spec("component", function() {
|
|||
}
|
||||
}
|
||||
render(root, [{tag: component}])
|
||||
|
||||
|
||||
o(root.firstChild.nodeType).equals(3)
|
||||
o(root.firstChild.nodeValue).equals("0")
|
||||
})
|
||||
|
|
@ -156,7 +156,7 @@ o.spec("component", function() {
|
|||
}
|
||||
}
|
||||
render(root, [{tag: component}])
|
||||
|
||||
|
||||
o(root.firstChild.nodeType).equals(3)
|
||||
o(root.firstChild.nodeValue).equals("true")
|
||||
})
|
||||
|
|
@ -167,7 +167,7 @@ o.spec("component", function() {
|
|||
}
|
||||
}
|
||||
render(root, [{tag: component}])
|
||||
|
||||
|
||||
o(root.firstChild.nodeType).equals(3)
|
||||
o(root.firstChild.nodeValue).equals("false")
|
||||
})
|
||||
|
|
@ -178,7 +178,7 @@ o.spec("component", function() {
|
|||
}
|
||||
}
|
||||
render(root, [{tag: component}])
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(0)
|
||||
})
|
||||
o("can return undefined", function() {
|
||||
|
|
@ -188,7 +188,7 @@ o.spec("component", function() {
|
|||
}
|
||||
}
|
||||
render(root, [{tag: component}])
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(0)
|
||||
})
|
||||
o("can update when returning fragments", function() {
|
||||
|
|
@ -202,7 +202,7 @@ o.spec("component", function() {
|
|||
}
|
||||
render(root, [{tag: component}])
|
||||
render(root, [{tag: component}])
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(2)
|
||||
o(root.childNodes[0].nodeName).equals("LABEL")
|
||||
o(root.childNodes[1].nodeName).equals("INPUT")
|
||||
|
|
@ -215,7 +215,7 @@ o.spec("component", function() {
|
|||
}
|
||||
render(root, [{tag: component}])
|
||||
render(root, [{tag: component}])
|
||||
|
||||
|
||||
o(root.firstChild.nodeType).equals(3)
|
||||
o(root.firstChild.nodeValue).equals("a")
|
||||
})
|
||||
|
|
@ -227,7 +227,7 @@ o.spec("component", function() {
|
|||
}
|
||||
render(root, [{tag: component}])
|
||||
render(root, [{tag: component}])
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(0)
|
||||
})
|
||||
o("can remove when returning fragments", function() {
|
||||
|
|
@ -241,9 +241,9 @@ o.spec("component", function() {
|
|||
}
|
||||
var div = {tag: "div", key: 2}
|
||||
render(root, [{tag: component, key: 1}, div])
|
||||
|
||||
|
||||
render(root, [{tag: "div", key: 2}])
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(1)
|
||||
o(root.firstChild).equals(div.dom)
|
||||
})
|
||||
|
|
@ -255,9 +255,9 @@ o.spec("component", function() {
|
|||
}
|
||||
var div = {tag: "div", key: 2}
|
||||
render(root, [{tag: component, key: 1}, div])
|
||||
|
||||
|
||||
render(root, [{tag: "div", key: 2}])
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(1)
|
||||
o(root.firstChild).equals(div.dom)
|
||||
})
|
||||
|
|
@ -268,7 +268,7 @@ o.spec("component", function() {
|
|||
var component = {
|
||||
oninit: function(vnode) {
|
||||
called++
|
||||
|
||||
|
||||
o(vnode.tag).equals(component)
|
||||
o(vnode.dom).equals(undefined)
|
||||
o(root.childNodes.length).equals(0)
|
||||
|
|
@ -278,9 +278,9 @@ o.spec("component", function() {
|
|||
}
|
||||
}
|
||||
var node = {tag: component}
|
||||
|
||||
|
||||
render(root, [node])
|
||||
|
||||
|
||||
o(called).equals(1)
|
||||
o(root.firstChild.nodeName).equals("DIV")
|
||||
o(root.firstChild.attributes["id"].nodeValue).equals("a")
|
||||
|
|
@ -291,7 +291,7 @@ o.spec("component", function() {
|
|||
var component = {
|
||||
oninit: function(vnode) {
|
||||
called++
|
||||
|
||||
|
||||
o(vnode.tag).equals(component)
|
||||
o(vnode.dom).equals(undefined)
|
||||
o(root.childNodes.length).equals(0)
|
||||
|
|
@ -301,9 +301,9 @@ o.spec("component", function() {
|
|||
}
|
||||
}
|
||||
var node = {tag: component}
|
||||
|
||||
|
||||
render(root, [node])
|
||||
|
||||
|
||||
o(called).equals(1)
|
||||
o(root.firstChild.nodeName).equals("DIV")
|
||||
o(root.firstChild.attributes["id"].nodeValue).equals("a")
|
||||
|
|
@ -311,7 +311,7 @@ o.spec("component", function() {
|
|||
})
|
||||
o("calls oninit before view", function() {
|
||||
var viewCalled = false
|
||||
|
||||
|
||||
render(root, {
|
||||
tag: {
|
||||
view: function() {
|
||||
|
|
@ -332,14 +332,14 @@ o.spec("component", function() {
|
|||
},
|
||||
oninit: init,
|
||||
}
|
||||
|
||||
|
||||
function view() {
|
||||
return {tag: component}
|
||||
}
|
||||
|
||||
|
||||
render(root, view())
|
||||
render(root, view())
|
||||
|
||||
|
||||
o(init.callCount).equals(1)
|
||||
})
|
||||
o("calls oncreate", function() {
|
||||
|
|
@ -347,7 +347,7 @@ o.spec("component", function() {
|
|||
var component = {
|
||||
oncreate: function(vnode) {
|
||||
called++
|
||||
|
||||
|
||||
o(vnode.dom).notEquals(undefined)
|
||||
o(vnode.dom).equals(root.firstChild)
|
||||
o(root.childNodes.length).equals(1)
|
||||
|
|
@ -357,9 +357,9 @@ o.spec("component", function() {
|
|||
}
|
||||
}
|
||||
var node = {tag: component}
|
||||
|
||||
|
||||
render(root, [node])
|
||||
|
||||
|
||||
o(called).equals(1)
|
||||
o(root.firstChild.nodeName).equals("DIV")
|
||||
o(root.firstChild.attributes["id"].nodeValue).equals("a")
|
||||
|
|
@ -373,14 +373,14 @@ o.spec("component", function() {
|
|||
},
|
||||
oncreate: create,
|
||||
}
|
||||
|
||||
|
||||
function view() {
|
||||
return {tag: component}
|
||||
}
|
||||
|
||||
|
||||
render(root, view())
|
||||
render(root, view())
|
||||
|
||||
|
||||
o(create.callCount).equals(1)
|
||||
})
|
||||
o("calls oncreate when returning fragment", function() {
|
||||
|
|
@ -388,7 +388,7 @@ o.spec("component", function() {
|
|||
var component = {
|
||||
oncreate: function(vnode) {
|
||||
called++
|
||||
|
||||
|
||||
o(vnode.dom).notEquals(undefined)
|
||||
o(vnode.dom).equals(root.firstChild)
|
||||
o(root.childNodes.length).equals(1)
|
||||
|
|
@ -398,9 +398,9 @@ o.spec("component", function() {
|
|||
}
|
||||
}
|
||||
var node = {tag: component}
|
||||
|
||||
|
||||
render(root, [node])
|
||||
|
||||
|
||||
o(called).equals(1)
|
||||
o(root.firstChild.nodeName).equals("DIV")
|
||||
o(root.firstChild.attributes["id"].nodeValue).equals("a")
|
||||
|
|
@ -411,7 +411,7 @@ o.spec("component", function() {
|
|||
var component = {
|
||||
onupdate: function(vnode) {
|
||||
called++
|
||||
|
||||
|
||||
o(vnode.dom).notEquals(undefined)
|
||||
o(vnode.dom).equals(root.firstChild)
|
||||
o(root.childNodes.length).equals(1)
|
||||
|
|
@ -420,13 +420,13 @@ o.spec("component", function() {
|
|||
return {tag: "div", attrs: {id: "a"}, text: "b"}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
render(root, [{tag: component}])
|
||||
|
||||
|
||||
o(called).equals(0)
|
||||
|
||||
render(root, [{tag: component}])
|
||||
|
||||
|
||||
o(called).equals(1)
|
||||
o(root.firstChild.nodeName).equals("DIV")
|
||||
o(root.firstChild.attributes["id"].nodeValue).equals("a")
|
||||
|
|
@ -437,7 +437,7 @@ o.spec("component", function() {
|
|||
var component = {
|
||||
onupdate: function(vnode) {
|
||||
called++
|
||||
|
||||
|
||||
o(vnode.dom).notEquals(undefined)
|
||||
o(vnode.dom).equals(root.firstChild)
|
||||
o(root.childNodes.length).equals(1)
|
||||
|
|
@ -446,13 +446,13 @@ o.spec("component", function() {
|
|||
return [{tag: "div", attrs: {id: "a"}, text: "b"}]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
render(root, [{tag: component}])
|
||||
|
||||
|
||||
o(called).equals(0)
|
||||
|
||||
render(root, [{tag: component}])
|
||||
|
||||
|
||||
o(called).equals(1)
|
||||
o(root.firstChild.nodeName).equals("DIV")
|
||||
o(root.firstChild.attributes["id"].nodeValue).equals("a")
|
||||
|
|
@ -463,7 +463,7 @@ o.spec("component", function() {
|
|||
var component = {
|
||||
onremove: function(vnode) {
|
||||
called++
|
||||
|
||||
|
||||
o(vnode.dom).notEquals(undefined)
|
||||
o(vnode.dom).equals(root.firstChild)
|
||||
o(root.childNodes.length).equals(1)
|
||||
|
|
@ -472,13 +472,13 @@ o.spec("component", function() {
|
|||
return {tag: "div", attrs: {id: "a"}, text: "b"}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
render(root, [{tag: component}])
|
||||
|
||||
|
||||
o(called).equals(0)
|
||||
|
||||
render(root, [])
|
||||
|
||||
|
||||
o(called).equals(1)
|
||||
o(root.childNodes.length).equals(0)
|
||||
})
|
||||
|
|
@ -487,7 +487,7 @@ o.spec("component", function() {
|
|||
var component = {
|
||||
onremove: function(vnode) {
|
||||
called++
|
||||
|
||||
|
||||
o(vnode.dom).notEquals(undefined)
|
||||
o(vnode.dom).equals(root.firstChild)
|
||||
o(root.childNodes.length).equals(1)
|
||||
|
|
@ -496,13 +496,13 @@ o.spec("component", function() {
|
|||
return [{tag: "div", attrs: {id: "a"}, text: "b"}]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
render(root, [{tag: component}])
|
||||
|
||||
|
||||
o(called).equals(0)
|
||||
|
||||
render(root, [])
|
||||
|
||||
|
||||
o(called).equals(1)
|
||||
o(root.childNodes.length).equals(0)
|
||||
})
|
||||
|
|
@ -511,24 +511,24 @@ o.spec("component", function() {
|
|||
var component = {
|
||||
onbeforeremove: function(vnode, done) {
|
||||
called++
|
||||
|
||||
|
||||
o(vnode.dom).notEquals(undefined)
|
||||
o(vnode.dom).equals(root.firstChild)
|
||||
o(root.childNodes.length).equals(1)
|
||||
|
||||
|
||||
done()
|
||||
},
|
||||
view: function() {
|
||||
return {tag: "div", attrs: {id: "a"}, text: "b"}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
render(root, [{tag: component}])
|
||||
|
||||
|
||||
o(called).equals(0)
|
||||
|
||||
render(root, [])
|
||||
|
||||
|
||||
o(called).equals(1)
|
||||
o(root.childNodes.length).equals(0)
|
||||
})
|
||||
|
|
@ -537,24 +537,24 @@ o.spec("component", function() {
|
|||
var component = {
|
||||
onbeforeremove: function(vnode, done) {
|
||||
called++
|
||||
|
||||
|
||||
o(vnode.dom).notEquals(undefined)
|
||||
o(vnode.dom).equals(root.firstChild)
|
||||
o(root.childNodes.length).equals(1)
|
||||
|
||||
|
||||
done()
|
||||
},
|
||||
view: function() {
|
||||
return [{tag: "div", attrs: {id: "a"}, text: "b"}]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
render(root, [{tag: component}])
|
||||
|
||||
|
||||
o(called).equals(0)
|
||||
|
||||
render(root, [])
|
||||
|
||||
|
||||
o(called).equals(1)
|
||||
o(root.childNodes.length).equals(0)
|
||||
})
|
||||
|
|
@ -568,11 +568,11 @@ o.spec("component", function() {
|
|||
var update = o.spy()
|
||||
var vnode = {tag: component, key: 1}
|
||||
var updated = {tag: component, key: 1}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(vnode.dom).notEquals(updated.dom)
|
||||
})
|
||||
})
|
||||
|
|
@ -586,12 +586,12 @@ o.spec("component", function() {
|
|||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
render(root, [{tag: component}])
|
||||
|
||||
|
||||
function init(vnode) {
|
||||
o(vnode.state.data).deepEquals([{a: 1}])
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -15,13 +15,13 @@ o.spec("createElement", function() {
|
|||
o("creates element", function() {
|
||||
var vnode = {tag: "div"}
|
||||
render(root, [vnode])
|
||||
|
||||
|
||||
o(vnode.dom.nodeName).equals("DIV")
|
||||
})
|
||||
o("creates attr", function() {
|
||||
var vnode = {tag: "div", attrs: {id: "a", title: "b"}}
|
||||
render(root, [vnode])
|
||||
|
||||
|
||||
o(vnode.dom.nodeName).equals("DIV")
|
||||
o(vnode.dom.attributes["id"].nodeValue).equals("a")
|
||||
o(vnode.dom.attributes["title"].nodeValue).equals("b")
|
||||
|
|
@ -29,14 +29,14 @@ o.spec("createElement", function() {
|
|||
o("creates style", function() {
|
||||
var vnode = {tag: "div", attrs: {style: {backgroundColor: "red"}}}
|
||||
render(root, [vnode])
|
||||
|
||||
|
||||
o(vnode.dom.nodeName).equals("DIV")
|
||||
o(vnode.dom.style.backgroundColor).equals("red")
|
||||
})
|
||||
o("creates children", function() {
|
||||
var vnode = {tag: "div", children: [{tag: "a"}, {tag: "b"}]}
|
||||
render(root, [vnode])
|
||||
|
||||
|
||||
o(vnode.dom.nodeName).equals("DIV")
|
||||
o(vnode.dom.childNodes.length).equals(2)
|
||||
o(vnode.dom.childNodes[0].nodeName).equals("A")
|
||||
|
|
@ -45,7 +45,7 @@ o.spec("createElement", function() {
|
|||
o("creates attrs and children", function() {
|
||||
var vnode = {tag: "div", attrs: {id: "a", title: "b"}, children: [{tag: "a"}, {tag: "b"}]}
|
||||
render(root, [vnode])
|
||||
|
||||
|
||||
o(vnode.dom.nodeName).equals("DIV")
|
||||
o(vnode.dom.attributes["id"].nodeValue).equals("a")
|
||||
o(vnode.dom.attributes["title"].nodeValue).equals("b")
|
||||
|
|
@ -56,7 +56,7 @@ o.spec("createElement", function() {
|
|||
o("creates svg", function() {
|
||||
var vnode = {tag: "svg", ns: "http://www.w3.org/2000/svg", children: [{tag: "a", ns: "http://www.w3.org/2000/svg", attrs: {"xlink:href": "javascript:;"}}]}
|
||||
render(root, [vnode])
|
||||
|
||||
|
||||
o(vnode.dom.nodeName).equals("svg")
|
||||
o(vnode.dom.namespaceURI).equals("http://www.w3.org/2000/svg")
|
||||
o(vnode.dom.firstChild.nodeName).equals("a")
|
||||
|
|
@ -67,13 +67,13 @@ o.spec("createElement", function() {
|
|||
o("sets attributes correctly for svg", function() {
|
||||
var vnode = {tag: "svg", ns: "http://www.w3.org/2000/svg", attrs: {viewBox: "0 0 100 100"}}
|
||||
render(root, [vnode])
|
||||
|
||||
|
||||
o(vnode.dom.attributes["viewBox"].nodeValue).equals("0 0 100 100")
|
||||
})
|
||||
o("creates mathml", function() {
|
||||
var vnode = {tag: "math", ns: "http://www.w3.org/1998/Math/MathML", children: [{tag: "mrow", ns: "http://www.w3.org/1998/Math/MathML"}]}
|
||||
render(root, [vnode])
|
||||
|
||||
|
||||
o(vnode.dom.nodeName).equals("math")
|
||||
o(vnode.dom.namespaceURI).equals("http://www.w3.org/1998/Math/MathML")
|
||||
o(vnode.dom.firstChild.nodeName).equals("mrow")
|
||||
|
|
|
|||
|
|
@ -15,27 +15,27 @@ o.spec("createFragment", function() {
|
|||
o("creates fragment", function() {
|
||||
var vnode = {tag: "[", children: [{tag: "a"}]}
|
||||
render(root, [vnode])
|
||||
|
||||
|
||||
o(vnode.dom.nodeName).equals("A")
|
||||
})
|
||||
o("handles empty fragment", function() {
|
||||
var vnode = {tag: "[", children: []}
|
||||
render(root, [vnode])
|
||||
|
||||
|
||||
o(vnode.dom).equals(null)
|
||||
o(vnode.domSize).equals(0)
|
||||
})
|
||||
o("handles childless fragment", function() {
|
||||
var vnode = {tag: "["}
|
||||
render(root, [vnode])
|
||||
|
||||
|
||||
o(vnode.dom).equals(null)
|
||||
o(vnode.domSize).equals(0)
|
||||
})
|
||||
o("handles multiple children", function() {
|
||||
var vnode = {tag: "[", children: [{tag: "a"}, {tag: "b"}]}
|
||||
render(root, [vnode])
|
||||
|
||||
|
||||
o(vnode.domSize).equals(2)
|
||||
o(vnode.dom.nodeName).equals("A")
|
||||
o(vnode.dom.nextSibling.nodeName).equals("B")
|
||||
|
|
@ -43,7 +43,7 @@ o.spec("createFragment", function() {
|
|||
o("handles td", function() {
|
||||
var vnode = {tag: "[", children: [{tag: "td"}]}
|
||||
render(root, [vnode])
|
||||
|
||||
|
||||
o(vnode.dom).notEquals(null)
|
||||
o(vnode.dom.nodeName).equals("TD")
|
||||
})
|
||||
|
|
|
|||
|
|
@ -15,26 +15,26 @@ o.spec("createHTML", function() {
|
|||
o("creates HTML", function() {
|
||||
var vnode = {tag: "<", children: "<a></a>"}
|
||||
render(root, [vnode])
|
||||
|
||||
|
||||
o(vnode.dom.nodeName).equals("A")
|
||||
})
|
||||
o("creates text HTML", function() {
|
||||
var vnode = {tag: "<", children: "a"}
|
||||
render(root, [vnode])
|
||||
|
||||
|
||||
o(vnode.dom.nodeValue).equals("a")
|
||||
})
|
||||
o("handles empty HTML", function() {
|
||||
var vnode = {tag: "<", children: ""}
|
||||
render(root, [vnode])
|
||||
|
||||
|
||||
o(vnode.dom).equals(null)
|
||||
o(vnode.domSize).equals(0)
|
||||
})
|
||||
o("handles multiple children", function() {
|
||||
var vnode = {tag: "<", children: "<a></a><b></b>"}
|
||||
render(root, [vnode])
|
||||
|
||||
|
||||
o(vnode.domSize).equals(2)
|
||||
o(vnode.dom.nodeName).equals("A")
|
||||
o(vnode.dom.nextSibling.nodeName).equals("B")
|
||||
|
|
@ -43,11 +43,11 @@ o.spec("createHTML", function() {
|
|||
//FIXME body,head,html,frame,frameset are not supported
|
||||
//FIXME keygen is broken in Firefox
|
||||
var tags = ["a", "abbr", "acronym", "address", "applet", "area", "article", "aside", "audio", "b", "base", "basefont", "bdi", "bdo", "big", "blockquote", /*"body",*/ "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "datalist", "dd", "del", "details", "dfn", "dialog", "dir", "div", "dl", "dt", "em", "embed", "fieldset", "figcaption", "figure", "font", "footer", "form", /*"frame", "frameset",*/ "h1", "h2", "h3", "h4", "h5", "h6", /*"head",*/ "header", "hr", /*"html",*/ "i", "iframe", "img", "input", "ins", "kbd", /*"keygen", */"label", "legend", "li", "link", "main", "map", "mark", "menu", "menuitem", "meta", "meter", "nav", "noframes", "noscript", "object", "ol", "optgroup", "option", "output", "p", "param", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "script", "section", "select", "small", "source", "span", "strike", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "textarea", "tfoot", "th", "thead", "time", "title", "tr", "track", "tt", "u", "ul", "var", "video", "wbr"]
|
||||
|
||||
|
||||
tags.forEach(function(tag) {
|
||||
var vnode = {tag: "<", children: "<" + tag + " />"}
|
||||
render(root, [vnode])
|
||||
|
||||
|
||||
o(vnode.dom.nodeName).equals(tag.toUpperCase())
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ o.spec("createNodes", function() {
|
|||
{tag: "[", children: [{tag: "#", children: "d"}]},
|
||||
]
|
||||
render(root, vnodes)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(4)
|
||||
o(root.childNodes[0].nodeName).equals("A")
|
||||
o(root.childNodes[1].nodeValue).equals("b")
|
||||
|
|
@ -36,7 +36,7 @@ o.spec("createNodes", function() {
|
|||
{tag: "[", children: [{tag: "#", children: "d"}]},
|
||||
]
|
||||
render(root, vnodes)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(4)
|
||||
o(root.childNodes[0].nodeName).equals("A")
|
||||
o(root.childNodes[1].nodeValue).equals("b")
|
||||
|
|
@ -52,7 +52,7 @@ o.spec("createNodes", function() {
|
|||
{tag: "[", children: [{tag: "#", children: "d"}]},
|
||||
]
|
||||
render(root, vnodes)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(4)
|
||||
o(root.childNodes[0].nodeName).equals("A")
|
||||
o(root.childNodes[1].nodeValue).equals("b")
|
||||
|
|
|
|||
|
|
@ -15,56 +15,56 @@ o.spec("createText", function() {
|
|||
o("creates string", function() {
|
||||
var vnode = {tag: "#", children: "a"}
|
||||
render(root, [vnode])
|
||||
|
||||
|
||||
o(vnode.dom.nodeName).equals("#text")
|
||||
o(vnode.dom.nodeValue).equals("a")
|
||||
})
|
||||
o("creates falsy string", function() {
|
||||
var vnode = {tag: "#", children: ""}
|
||||
render(root, [vnode])
|
||||
|
||||
|
||||
o(vnode.dom.nodeName).equals("#text")
|
||||
o(vnode.dom.nodeValue).equals("")
|
||||
})
|
||||
o("creates number", function() {
|
||||
var vnode = {tag: "#", children: 1}
|
||||
render(root, [vnode])
|
||||
|
||||
|
||||
o(vnode.dom.nodeName).equals("#text")
|
||||
o(vnode.dom.nodeValue).equals("1")
|
||||
})
|
||||
o("creates falsy number", function() {
|
||||
var vnode = {tag: "#", children: 0}
|
||||
render(root, [vnode])
|
||||
|
||||
|
||||
o(vnode.dom.nodeName).equals("#text")
|
||||
o(vnode.dom.nodeValue).equals("0")
|
||||
})
|
||||
o("creates boolean", function() {
|
||||
var vnode = {tag: "#", children: true}
|
||||
render(root, [vnode])
|
||||
|
||||
|
||||
o(vnode.dom.nodeName).equals("#text")
|
||||
o(vnode.dom.nodeValue).equals("true")
|
||||
})
|
||||
o("creates falsy boolean", function() {
|
||||
var vnode = {tag: "#", children: false}
|
||||
render(root, [vnode])
|
||||
|
||||
|
||||
o(vnode.dom.nodeName).equals("#text")
|
||||
o(vnode.dom.nodeValue).equals("false")
|
||||
})
|
||||
o("creates spaces", function() {
|
||||
var vnode = {tag: "#", children: " "}
|
||||
render(root, [vnode])
|
||||
|
||||
|
||||
o(vnode.dom.nodeName).equals("#text")
|
||||
o(vnode.dom.nodeValue).equals(" ")
|
||||
})
|
||||
o("ignores html", function() {
|
||||
var vnode = {tag: "#", children: "<a></a>™"}
|
||||
render(root, [vnode])
|
||||
|
||||
|
||||
o(vnode.dom.nodeName).equals("#text")
|
||||
o(vnode.dom.nodeValue).equals("<a></a>™")
|
||||
})
|
||||
|
|
|
|||
|
|
@ -20,10 +20,10 @@ o.spec("event", function() {
|
|||
var div = {tag: "div", attrs: {onclick: spy}}
|
||||
var e = $window.document.createEvent("MouseEvents")
|
||||
e.initEvent("click", true, true)
|
||||
|
||||
|
||||
render(root, [div])
|
||||
div.dom.dispatchEvent(e)
|
||||
|
||||
|
||||
o(spy.callCount).equals(1)
|
||||
o(spy.this).equals(div.dom)
|
||||
o(spy.args[0].type).equals("click")
|
||||
|
|
@ -40,11 +40,11 @@ o.spec("event", function() {
|
|||
var updated = {tag: "div", attrs: {id: "b", onclick: spy}}
|
||||
var e = $window.document.createEvent("MouseEvents")
|
||||
e.initEvent("click", true, true)
|
||||
|
||||
|
||||
render(root, [div])
|
||||
render(root, [updated])
|
||||
div.dom.dispatchEvent(e)
|
||||
|
||||
|
||||
o(spy.callCount).equals(1)
|
||||
o(spy.this).equals(div.dom)
|
||||
o(spy.args[0].type).equals("click")
|
||||
|
|
@ -62,10 +62,10 @@ o.spec("event", function() {
|
|||
var div = {tag: "div", attrs: {ontransitionend: spy}}
|
||||
var e = $window.document.createEvent("HTMLEvents")
|
||||
e.initEvent("transitionend", true, true)
|
||||
|
||||
|
||||
render(root, [div])
|
||||
div.dom.dispatchEvent(e)
|
||||
|
||||
|
||||
o(spy.callCount).equals(1)
|
||||
o(spy.this).equals(div.dom)
|
||||
o(spy.args[0].type).equals("transitionend")
|
||||
|
|
@ -75,4 +75,4 @@ o.spec("event", function() {
|
|||
o(onevent.args[0].type).equals("transitionend")
|
||||
o(onevent.args[0].target).equals(div.dom)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -5,55 +5,55 @@ o.spec("hyperscript", function() {
|
|||
o.spec("selector", function() {
|
||||
o("handles tag in selector", function() {
|
||||
var vnode = m("a")
|
||||
|
||||
|
||||
o(vnode.tag).equals("a")
|
||||
})
|
||||
o("handles class in selector", function() {
|
||||
var vnode = m(".a")
|
||||
|
||||
|
||||
o(vnode.tag).equals("div")
|
||||
o(vnode.attrs.className).equals("a")
|
||||
})
|
||||
o("handles many classes in selector", function() {
|
||||
var vnode = m(".a.b.c")
|
||||
|
||||
|
||||
o(vnode.tag).equals("div")
|
||||
o(vnode.attrs.className).equals("a b c")
|
||||
})
|
||||
o("handles id in selector", function() {
|
||||
var vnode = m("#a")
|
||||
|
||||
|
||||
o(vnode.tag).equals("div")
|
||||
o(vnode.attrs.id).equals("a")
|
||||
})
|
||||
o("handles attr in selector", function() {
|
||||
var vnode = m("[a=b]")
|
||||
|
||||
|
||||
o(vnode.tag).equals("div")
|
||||
o(vnode.attrs.a).equals("b")
|
||||
})
|
||||
o("handles many attrs in selector", function() {
|
||||
var vnode = m("[a=b][c=d]")
|
||||
|
||||
|
||||
o(vnode.tag).equals("div")
|
||||
o(vnode.attrs.a).equals("b")
|
||||
o(vnode.attrs.c).equals("d")
|
||||
})
|
||||
o("handles attr w/ spaces in selector", function() {
|
||||
var vnode = m("[a = b]")
|
||||
|
||||
|
||||
o(vnode.tag).equals("div")
|
||||
o(vnode.attrs.a).equals("b")
|
||||
})
|
||||
o("handles attr w/ quotes in selector", function() {
|
||||
var vnode = m("[a='b']")
|
||||
|
||||
|
||||
o(vnode.tag).equals("div")
|
||||
o(vnode.attrs.a).equals("b")
|
||||
})
|
||||
o("handles attr w/ quoted square bracket", function() {
|
||||
var vnode = m("[x][a='[b]'].c")
|
||||
|
||||
|
||||
o(vnode.tag).equals("div")
|
||||
o(vnode.attrs.x).equals(true)
|
||||
o(vnode.attrs.a).equals("[b]")
|
||||
|
|
@ -61,55 +61,55 @@ o.spec("hyperscript", function() {
|
|||
})
|
||||
o("handles attr w/ unmatched square bracket", function() {
|
||||
var vnode = m("[a=']'].c")
|
||||
|
||||
|
||||
o(vnode.tag).equals("div")
|
||||
o(vnode.attrs.a).equals("]")
|
||||
o(vnode.attrs.className).equals("c")
|
||||
})
|
||||
o("handles attr w/ quoted square bracket and quote", function() {
|
||||
var vnode = m("[a='[b\"\\']'].c") // `[a='[b"\']']`
|
||||
|
||||
|
||||
o(vnode.tag).equals("div")
|
||||
o(vnode.attrs.a).equals("[b\"']") // `[b"']`
|
||||
o(vnode.attrs.className).equals("c")
|
||||
})
|
||||
o("handles attr w/ quoted square containing escaped square bracket", function() {
|
||||
var vnode = m("[a='[\\]]'].c") // `[a='[\]]']`
|
||||
|
||||
|
||||
o(vnode.tag).equals("div")
|
||||
o(vnode.attrs.a).equals("[\\]]") // `[\]]`
|
||||
o(vnode.attrs.className).equals("c")
|
||||
})
|
||||
o("handles attr w/ backslashes", function() {
|
||||
var vnode = m("[a='\\\\'].c") // `[a='\\']`
|
||||
|
||||
|
||||
o(vnode.tag).equals("div")
|
||||
o(vnode.attrs.a).equals("\\")
|
||||
o(vnode.attrs.className).equals("c")
|
||||
})
|
||||
o("handles attr w/ quotes and spaces in selector", function() {
|
||||
var vnode = m("[a = 'b']")
|
||||
|
||||
|
||||
o(vnode.tag).equals("div")
|
||||
o(vnode.attrs.a).equals("b")
|
||||
})
|
||||
o("handles many attr w/ quotes and spaces in selector", function() {
|
||||
var vnode = m("[a = 'b'][c = 'd']")
|
||||
|
||||
|
||||
o(vnode.tag).equals("div")
|
||||
o(vnode.attrs.a).equals("b")
|
||||
o(vnode.attrs.c).equals("d")
|
||||
})
|
||||
o("handles tag, class, attrs in selector", function() {
|
||||
var vnode = m("a.b[c = 'd']")
|
||||
|
||||
|
||||
o(vnode.tag).equals("a")
|
||||
o(vnode.attrs.className).equals("b")
|
||||
o(vnode.attrs.c).equals("d")
|
||||
})
|
||||
o("handles tag, mixed classes, attrs in selector", function() {
|
||||
var vnode = m("a.b[c = 'd'].e[f = 'g']")
|
||||
|
||||
|
||||
o(vnode.tag).equals("a")
|
||||
o(vnode.attrs.className).equals("b e")
|
||||
o(vnode.attrs.c).equals("d")
|
||||
|
|
@ -117,7 +117,7 @@ o.spec("hyperscript", function() {
|
|||
})
|
||||
o("handles attr without value", function() {
|
||||
var vnode = m("[a]")
|
||||
|
||||
|
||||
o(vnode.tag).equals("div")
|
||||
o(vnode.attrs.a).equals(true)
|
||||
})
|
||||
|
|
@ -125,102 +125,102 @@ o.spec("hyperscript", function() {
|
|||
o.spec("attrs", function() {
|
||||
o("handles string attr", function() {
|
||||
var vnode = m("div", {a: "b"})
|
||||
|
||||
|
||||
o(vnode.tag).equals("div")
|
||||
o(vnode.attrs.a).equals("b")
|
||||
})
|
||||
o("handles falsy string attr", function() {
|
||||
var vnode = m("div", {a: ""})
|
||||
|
||||
|
||||
o(vnode.tag).equals("div")
|
||||
o(vnode.attrs.a).equals("")
|
||||
})
|
||||
o("handles number attr", function() {
|
||||
var vnode = m("div", {a: 1})
|
||||
|
||||
|
||||
o(vnode.tag).equals("div")
|
||||
o(vnode.attrs.a).equals(1)
|
||||
})
|
||||
o("handles falsy number attr", function() {
|
||||
var vnode = m("div", {a: 0})
|
||||
|
||||
|
||||
o(vnode.tag).equals("div")
|
||||
o(vnode.attrs.a).equals(0)
|
||||
})
|
||||
o("handles boolean attr", function() {
|
||||
var vnode = m("div", {a: true})
|
||||
|
||||
|
||||
o(vnode.tag).equals("div")
|
||||
o(vnode.attrs.a).equals(true)
|
||||
})
|
||||
o("handles falsy boolean attr", function() {
|
||||
var vnode = m("div", {a: false})
|
||||
|
||||
|
||||
o(vnode.tag).equals("div")
|
||||
o(vnode.attrs.a).equals(false)
|
||||
})
|
||||
o("handles many attrs", function() {
|
||||
var vnode = m("div", {a: "b", c: "d"})
|
||||
|
||||
|
||||
o(vnode.tag).equals("div")
|
||||
o(vnode.attrs.a).equals("b")
|
||||
o(vnode.attrs.c).equals("d")
|
||||
})
|
||||
o("handles merging classes w/ class property", function() {
|
||||
var vnode = m(".a", {class: "b"})
|
||||
|
||||
|
||||
o(vnode.attrs.className).equals("a b")
|
||||
})
|
||||
o("handles merging classes w/ className property", function() {
|
||||
var vnode = m(".a", {className: "b"})
|
||||
|
||||
|
||||
o(vnode.attrs.className).equals("a b")
|
||||
})
|
||||
})
|
||||
o.spec("children", function() {
|
||||
o("handles string single child", function() {
|
||||
var vnode = m("div", {}, ["a"])
|
||||
|
||||
|
||||
o(vnode.text).equals("a")
|
||||
})
|
||||
o("handles falsy string single child", function() {
|
||||
var vnode = m("div", {}, [""])
|
||||
|
||||
|
||||
o(vnode.text).equals("")
|
||||
})
|
||||
o("handles number single child", function() {
|
||||
var vnode = m("div", {}, [1])
|
||||
|
||||
|
||||
o(vnode.text).equals(1)
|
||||
})
|
||||
o("handles falsy number single child", function() {
|
||||
var vnode = m("div", {}, [0])
|
||||
|
||||
|
||||
o(vnode.text).equals(0)
|
||||
})
|
||||
o("handles boolean single child", function() {
|
||||
var vnode = m("div", {}, [true])
|
||||
|
||||
|
||||
o(vnode.text).equals(true)
|
||||
})
|
||||
o("handles falsy boolean single child", function() {
|
||||
var vnode = m("div", {}, [false])
|
||||
|
||||
|
||||
o(vnode.text).equals(false)
|
||||
})
|
||||
o("handles null single child", function() {
|
||||
var vnode = m("div", {}, [null])
|
||||
|
||||
|
||||
o(vnode.children[0]).equals(null)
|
||||
})
|
||||
o("handles undefined single child", function() {
|
||||
var vnode = m("div", {}, [undefined])
|
||||
|
||||
|
||||
o(vnode.children[0]).equals(undefined)
|
||||
})
|
||||
o("handles multiple string children", function() {
|
||||
var vnode = m("div", {}, ["", "a"])
|
||||
|
||||
|
||||
o(vnode.children[0].tag).equals("#")
|
||||
o(vnode.children[0].children).equals("")
|
||||
o(vnode.children[1].tag).equals("#")
|
||||
|
|
@ -228,7 +228,7 @@ o.spec("hyperscript", function() {
|
|||
})
|
||||
o("handles multiple number children", function() {
|
||||
var vnode = m("div", {}, [0, 1])
|
||||
|
||||
|
||||
o(vnode.children[0].tag).equals("#")
|
||||
o(vnode.children[0].children).equals(0)
|
||||
o(vnode.children[1].tag).equals("#")
|
||||
|
|
@ -236,7 +236,7 @@ o.spec("hyperscript", function() {
|
|||
})
|
||||
o("handles multiple boolean children", function() {
|
||||
var vnode = m("div", {}, [false, true])
|
||||
|
||||
|
||||
o(vnode.children[0].tag).equals("#")
|
||||
o(vnode.children[0].children).equals(false)
|
||||
o(vnode.children[1].tag).equals("#")
|
||||
|
|
@ -244,7 +244,7 @@ o.spec("hyperscript", function() {
|
|||
})
|
||||
o("handles multiple null/undefined child", function() {
|
||||
var vnode = m("div", {}, [null, undefined])
|
||||
|
||||
|
||||
o(vnode.children[0]).equals(null)
|
||||
o(vnode.children[1]).equals(undefined)
|
||||
})
|
||||
|
|
@ -252,47 +252,47 @@ o.spec("hyperscript", function() {
|
|||
o.spec("permutations", function() {
|
||||
o("handles null attr and children", function() {
|
||||
var vnode = m("div", null, [m("a"), m("b")])
|
||||
|
||||
|
||||
o(vnode.children.length).equals(2)
|
||||
o(vnode.children[0].tag).equals("a")
|
||||
o(vnode.children[1].tag).equals("b")
|
||||
})
|
||||
o("handles null attr and child unwrapped", function() {
|
||||
var vnode = m("div", null, m("a"))
|
||||
|
||||
|
||||
o(vnode.children.length).equals(1)
|
||||
o(vnode.children[0].tag).equals("a")
|
||||
})
|
||||
o("handles null attr and children unwrapped", function() {
|
||||
var vnode = m("div", null, m("a"), m("b"))
|
||||
|
||||
|
||||
o(vnode.children.length).equals(2)
|
||||
o(vnode.children[0].tag).equals("a")
|
||||
o(vnode.children[1].tag).equals("b")
|
||||
})
|
||||
o("handles attr and children", function() {
|
||||
var vnode = m("div", {a: "b"}, [m("i"), m("s")])
|
||||
|
||||
|
||||
o(vnode.attrs.a).equals("b")
|
||||
o(vnode.children[0].tag).equals("i")
|
||||
o(vnode.children[1].tag).equals("s")
|
||||
})
|
||||
o("handles attr and child unwrapped", function() {
|
||||
var vnode = m("div", {a: "b"}, m("i"))
|
||||
|
||||
|
||||
o(vnode.attrs.a).equals("b")
|
||||
o(vnode.children[0].tag).equals("i")
|
||||
})
|
||||
o("handles attr and children unwrapped", function() {
|
||||
var vnode = m("div", {a: "b"}, m("i"), m("s"))
|
||||
|
||||
|
||||
o(vnode.attrs.a).equals("b")
|
||||
o(vnode.children[0].tag).equals("i")
|
||||
o(vnode.children[1].tag).equals("s")
|
||||
})
|
||||
o("handles attr and text children", function() {
|
||||
var vnode = m("div", {a: "b"}, ["c", "d"])
|
||||
|
||||
|
||||
o(vnode.attrs.a).equals("b")
|
||||
o(vnode.children[0].tag).equals("#")
|
||||
o(vnode.children[0].children).equals("c")
|
||||
|
|
@ -301,49 +301,49 @@ o.spec("hyperscript", function() {
|
|||
})
|
||||
o("handles attr and single string text child", function() {
|
||||
var vnode = m("div", {a: "b"}, ["c"])
|
||||
|
||||
|
||||
o(vnode.attrs.a).equals("b")
|
||||
o(vnode.text).equals("c")
|
||||
})
|
||||
o("handles attr and single falsy string text child", function() {
|
||||
var vnode = m("div", {a: "b"}, [""])
|
||||
|
||||
|
||||
o(vnode.attrs.a).equals("b")
|
||||
o(vnode.text).equals("")
|
||||
})
|
||||
o("handles attr and single number text child", function() {
|
||||
var vnode = m("div", {a: "b"}, [1])
|
||||
|
||||
|
||||
o(vnode.attrs.a).equals("b")
|
||||
o(vnode.text).equals(1)
|
||||
})
|
||||
o("handles attr and single falsy number text child", function() {
|
||||
var vnode = m("div", {a: "b"}, [0])
|
||||
|
||||
|
||||
o(vnode.attrs.a).equals("b")
|
||||
o(vnode.text).equals(0)
|
||||
})
|
||||
o("handles attr and single boolean text child", function() {
|
||||
var vnode = m("div", {a: "b"}, [true])
|
||||
|
||||
|
||||
o(vnode.attrs.a).equals("b")
|
||||
o(vnode.text).equals(true)
|
||||
})
|
||||
o("handles attr and single falsy boolean text child", function() {
|
||||
var vnode = m("div", {a: "b"}, [false])
|
||||
|
||||
|
||||
o(vnode.attrs.a).equals("b")
|
||||
o(vnode.text).equals(false)
|
||||
})
|
||||
o("handles attr and single text child unwrapped", function() {
|
||||
var vnode = m("div", {a: "b"}, "c")
|
||||
|
||||
|
||||
o(vnode.attrs.a).equals("b")
|
||||
o(vnode.text).equals("c")
|
||||
})
|
||||
o("handles attr and text children unwrapped", function() {
|
||||
var vnode = m("div", {a: "b"}, "c", "d")
|
||||
|
||||
|
||||
o(vnode.attrs.a).equals("b")
|
||||
o(vnode.children[0].tag).equals("#")
|
||||
o(vnode.children[0].children).equals("c")
|
||||
|
|
@ -352,27 +352,27 @@ o.spec("hyperscript", function() {
|
|||
})
|
||||
o("handles children without attr", function() {
|
||||
var vnode = m("div", [m("i"), m("s")])
|
||||
|
||||
|
||||
o(vnode.attrs).equals(undefined)
|
||||
o(vnode.children[0].tag).equals("i")
|
||||
o(vnode.children[1].tag).equals("s")
|
||||
})
|
||||
o("handles child without attr unwrapped", function() {
|
||||
var vnode = m("div", m("i"))
|
||||
|
||||
|
||||
o(vnode.attrs).equals(undefined)
|
||||
o(vnode.children[0].tag).equals("i")
|
||||
})
|
||||
o("handles children without attr unwrapped", function() {
|
||||
var vnode = m("div", m("i"), m("s"))
|
||||
|
||||
|
||||
o(vnode.attrs).equals(undefined)
|
||||
o(vnode.children[0].tag).equals("i")
|
||||
o(vnode.children[1].tag).equals("s")
|
||||
})
|
||||
o("handles fragment children without attr unwrapped", function() {
|
||||
var vnode = m("div", [m("i")], [m("s")])
|
||||
|
||||
|
||||
o(vnode.children[0].tag).equals("[")
|
||||
o(vnode.children[0].children[0].tag).equals("i")
|
||||
o(vnode.children[1].tag).equals("[")
|
||||
|
|
@ -380,14 +380,14 @@ o.spec("hyperscript", function() {
|
|||
})
|
||||
o("handles children with nested array", function() {
|
||||
var vnode = m("div", [[m("i"), m("s")]])
|
||||
|
||||
|
||||
o(vnode.children[0].tag).equals("[")
|
||||
o(vnode.children[0].children[0].tag).equals("i")
|
||||
o(vnode.children[0].children[1].tag).equals("s")
|
||||
})
|
||||
o("handles children with deeply nested array", function() {
|
||||
var vnode = m("div", [[[m("i"), m("s")]]])
|
||||
|
||||
|
||||
o(vnode.children[0].tag).equals("[")
|
||||
o(vnode.children[0].children[0].tag).equals("[")
|
||||
o(vnode.children[0].children[0].children[0].tag).equals("i")
|
||||
|
|
@ -402,7 +402,7 @@ o.spec("hyperscript", function() {
|
|||
}
|
||||
}
|
||||
var vnode = m(component, {id: "a"}, "b")
|
||||
|
||||
|
||||
o(vnode.tag).equals(component)
|
||||
o(vnode.attrs.id).equals("a")
|
||||
o(vnode.children.length).equals(1)
|
||||
|
|
@ -410,4 +410,4 @@ o.spec("hyperscript", function() {
|
|||
o(vnode.children[0].children).equals("b")
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -22,86 +22,86 @@ o.spec("form inputs", function() {
|
|||
var input = {tag: "input", key: 1}
|
||||
var a = {tag: "a", key: 2}
|
||||
var b = {tag: "b", key: 3}
|
||||
|
||||
|
||||
render(root, [input, a, b])
|
||||
input.dom.focus()
|
||||
render(root, [a, input, b])
|
||||
|
||||
|
||||
o($window.document.activeElement).equals(input.dom)
|
||||
})
|
||||
|
||||
|
||||
o("syncs input value if DOM value differs from vdom value", function() {
|
||||
var input = {tag: "input", attrs: {value: "aaa", oninput: function() {}}}
|
||||
var updated = {tag: "input", attrs: {value: "aaa", oninput: function() {}}}
|
||||
|
||||
|
||||
render(root, [input])
|
||||
|
||||
|
||||
//simulate user typing
|
||||
var e = $window.document.createEvent("KeyboardEvent")
|
||||
e.initEvent("input", true, true)
|
||||
input.dom.focus()
|
||||
input.dom.value += "a"
|
||||
input.dom.dispatchEvent(e)
|
||||
|
||||
|
||||
//re-render may use same vdom value as previous render call
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(updated.dom.value).equals("aaa")
|
||||
})
|
||||
|
||||
|
||||
o("syncs input checked attribute if DOM value differs from vdom value", function() {
|
||||
var input = {tag: "input", attrs: {type: "checkbox", checked: true, onclick: function() {}}}
|
||||
var updated = {tag: "input", attrs: {type: "checkbox", checked: true, onclick: function() {}}}
|
||||
|
||||
|
||||
render(root, [input])
|
||||
|
||||
|
||||
//simulate user clicking checkbox
|
||||
var e = $window.document.createEvent("MouseEvents")
|
||||
e.initEvent("click", true, true)
|
||||
input.dom.focus()
|
||||
input.dom.dispatchEvent(e)
|
||||
|
||||
|
||||
//re-render may use same vdom value as previous render call
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(updated.dom.checked).equals(true)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
o.spec("select", function() {
|
||||
o("select works without attributes", function() {
|
||||
var select = {tag: "select", children: [
|
||||
{tag: "option", attrs: {value: "a"}, text: "aaa"},
|
||||
]}
|
||||
|
||||
|
||||
render(root, [select])
|
||||
|
||||
|
||||
o(select.dom.value).equals("a")
|
||||
o(select.dom.selectedIndex).equals(0)
|
||||
})
|
||||
|
||||
|
||||
o("select yields invalid value without children", function() {
|
||||
var select = {tag: "select", attrs: {value: "a"}}
|
||||
|
||||
|
||||
render(root, [select])
|
||||
|
||||
|
||||
o(select.dom.value).equals("")
|
||||
o(select.dom.selectedIndex).equals(-1)
|
||||
})
|
||||
|
||||
|
||||
o("select value is set correctly on first render", function() {
|
||||
var select = {tag: "select", attrs: {value: "b"}, children: [
|
||||
{tag: "option", attrs: {value: "a"}, text: "aaa"},
|
||||
{tag: "option", attrs: {value: "b"}, text: "bbb"},
|
||||
{tag: "option", attrs: {value: "c"}, text: "ccc"},
|
||||
]}
|
||||
|
||||
|
||||
render(root, [select])
|
||||
|
||||
|
||||
o(select.dom.value).equals("b")
|
||||
o(select.dom.selectedIndex).equals(1)
|
||||
})
|
||||
|
||||
|
||||
o("syncs select value if DOM value differs from vdom value", function() {
|
||||
function makeSelect() {
|
||||
return {tag: "select", attrs: {value: "b"}, children: [
|
||||
|
|
@ -110,33 +110,33 @@ o.spec("form inputs", function() {
|
|||
{tag: "option", attrs: {value: "c"}, text: "ccc"},
|
||||
]}
|
||||
}
|
||||
|
||||
|
||||
render(root, [makeSelect()])
|
||||
|
||||
|
||||
//simulate user selecting option
|
||||
root.firstChild.value = "c"
|
||||
root.firstChild.focus()
|
||||
|
||||
|
||||
//re-render may use same vdom value as previous render call
|
||||
render(root, [makeSelect()])
|
||||
|
||||
|
||||
o(root.firstChild.value).equals("b")
|
||||
o(root.firstChild.selectedIndex).equals(1)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
o.spec("textarea", function() {
|
||||
o("updates after user input", function() {
|
||||
render(root, [{tag: "textarea", text: "aaa"}])
|
||||
|
||||
|
||||
//simulate typing
|
||||
root.firstChild.value = "bbb"
|
||||
|
||||
|
||||
//re-render may occur after value attribute is touched
|
||||
render(root, [{tag: "textarea", text: "ccc"}])
|
||||
|
||||
|
||||
o(root.firstChild.value).equals("ccc")
|
||||
//FIXME should fail if fix is commented out
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -6,13 +6,13 @@ var Node = require("../../render/node")
|
|||
o.spec("normalize", function() {
|
||||
o("normalizes array into fragment", function() {
|
||||
var node = Node.normalize([])
|
||||
|
||||
|
||||
o(node.tag).equals("[")
|
||||
o(node.children.length).equals(0)
|
||||
})
|
||||
o("normalizes nested array into fragment", function() {
|
||||
var node = Node.normalize([[]])
|
||||
|
||||
|
||||
o(node.tag).equals("[")
|
||||
o(node.children.length).equals(1)
|
||||
o(node.children[0].tag).equals("[")
|
||||
|
|
@ -20,39 +20,38 @@ o.spec("normalize", function() {
|
|||
})
|
||||
o("normalizes string into text node", function() {
|
||||
var node = Node.normalize("a")
|
||||
|
||||
|
||||
o(node.tag).equals("#")
|
||||
o(node.children).equals("a")
|
||||
})
|
||||
o("normalizes falsy string into text node", function() {
|
||||
var node = Node.normalize("")
|
||||
|
||||
|
||||
o(node.tag).equals("#")
|
||||
o(node.children).equals("")
|
||||
})
|
||||
o("normalizes number into text node", function() {
|
||||
var node = Node.normalize(1)
|
||||
|
||||
|
||||
o(node.tag).equals("#")
|
||||
o(node.children).equals(1)
|
||||
})
|
||||
o("normalizes falsy number into text node", function() {
|
||||
var node = Node.normalize(0)
|
||||
|
||||
|
||||
o(node.tag).equals("#")
|
||||
o(node.children).equals(0)
|
||||
})
|
||||
o("normalizes boolean into text node", function() {
|
||||
var node = Node.normalize(true)
|
||||
|
||||
|
||||
o(node.tag).equals("#")
|
||||
o(node.children).equals(true)
|
||||
})
|
||||
o("normalizes falsy boolean into text node", function() {
|
||||
var node = Node.normalize(false)
|
||||
|
||||
|
||||
o(node.tag).equals("#")
|
||||
o(node.children).equals(false)
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -6,15 +6,14 @@ var Node = require("../../render/node")
|
|||
o.spec("normalizeChildren", function() {
|
||||
o("normalizes arrays into fragments", function() {
|
||||
var children = Node.normalizeChildren([[]])
|
||||
|
||||
|
||||
o(children[0].tag).equals("[")
|
||||
o(children[0].children.length).equals(0)
|
||||
})
|
||||
o("normalizes strings into text nodes", function() {
|
||||
var children = Node.normalizeChildren(["a"])
|
||||
|
||||
|
||||
o(children[0].tag).equals("#")
|
||||
o(children[0].children).equals("a")
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@ o.spec("onbeforeremove", function() {
|
|||
var create = o.spy()
|
||||
var update = o.spy()
|
||||
var vnode = {tag: "div", attrs: {onbeforeremove: create}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
|
||||
|
||||
o(create.callCount).equals(0)
|
||||
})
|
||||
o("does not call onbeforeremove when updating", function() {
|
||||
|
|
@ -27,29 +27,29 @@ o.spec("onbeforeremove", function() {
|
|||
var update = o.spy()
|
||||
var vnode = {tag: "div", attrs: {onbeforeremove: create}}
|
||||
var updated = {tag: "div", attrs: {onbeforeremove: update}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(create.callCount).equals(0)
|
||||
o(update.callCount).equals(0)
|
||||
})
|
||||
o("calls onbeforeremove when removing element", function(done) {
|
||||
var vnode = {tag: "div", attrs: {onbeforeremove: remove}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [])
|
||||
|
||||
|
||||
function remove(node, complete) {
|
||||
o(node).equals(vnode)
|
||||
o(root.childNodes.length).equals(1)
|
||||
o(root.firstChild).equals(vnode.dom)
|
||||
|
||||
|
||||
callAsync(function() {
|
||||
o(root.childNodes.length).equals(1)
|
||||
|
||||
|
||||
complete()
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(0)
|
||||
|
||||
done()
|
||||
|
|
@ -58,20 +58,20 @@ o.spec("onbeforeremove", function() {
|
|||
})
|
||||
o("calls onbeforeremove when removing text", function(done) {
|
||||
var vnode = {tag: "#", attrs: {onbeforeremove: remove}, children: "a"}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [])
|
||||
|
||||
|
||||
function remove(node, complete) {
|
||||
o(node).equals(vnode)
|
||||
o(root.childNodes.length).equals(1)
|
||||
o(root.firstChild).equals(vnode.dom)
|
||||
|
||||
|
||||
callAsync(function() {
|
||||
o(root.childNodes.length).equals(1)
|
||||
|
||||
|
||||
complete()
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(0)
|
||||
|
||||
done()
|
||||
|
|
@ -80,20 +80,20 @@ o.spec("onbeforeremove", function() {
|
|||
})
|
||||
o("calls onbeforeremove when removing fragment", function(done) {
|
||||
var vnode = {tag: "[", attrs: {onbeforeremove: remove}, children: [{tag: "div"}]}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [])
|
||||
|
||||
|
||||
function remove(node, complete) {
|
||||
o(node).equals(vnode)
|
||||
o(root.childNodes.length).equals(1)
|
||||
o(root.firstChild).equals(vnode.dom)
|
||||
|
||||
|
||||
callAsync(function() {
|
||||
o(root.childNodes.length).equals(1)
|
||||
|
||||
|
||||
complete()
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(0)
|
||||
|
||||
done()
|
||||
|
|
@ -102,20 +102,20 @@ o.spec("onbeforeremove", function() {
|
|||
})
|
||||
o("calls onbeforeremove when removing html", function(done) {
|
||||
var vnode = {tag: "<", attrs: {onbeforeremove: remove}, children: "a"}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [])
|
||||
|
||||
|
||||
function remove(node, complete) {
|
||||
o(node).equals(vnode)
|
||||
o(root.childNodes.length).equals(1)
|
||||
o(root.firstChild).equals(vnode.dom)
|
||||
|
||||
|
||||
callAsync(function() {
|
||||
o(root.childNodes.length).equals(1)
|
||||
|
||||
|
||||
complete()
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(0)
|
||||
|
||||
done()
|
||||
|
|
@ -125,21 +125,21 @@ o.spec("onbeforeremove", function() {
|
|||
o("calls remove after onbeforeremove resolves", function(done) {
|
||||
var spy = o.spy()
|
||||
var vnode = {tag: "<", attrs: {onbeforeremove: remove, onremove: spy}, children: "a"}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [])
|
||||
|
||||
|
||||
function remove(node, complete) {
|
||||
o(node).equals(vnode)
|
||||
o(root.childNodes.length).equals(1)
|
||||
o(root.firstChild).equals(vnode.dom)
|
||||
|
||||
|
||||
callAsync(function() {
|
||||
o(root.childNodes.length).equals(1)
|
||||
o(spy.callCount).equals(0)
|
||||
|
||||
|
||||
complete()
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(0)
|
||||
o(spy.callCount).equals(1)
|
||||
|
||||
|
|
@ -150,9 +150,9 @@ o.spec("onbeforeremove", function() {
|
|||
o("does not set onbeforeremove as an event handler", function() {
|
||||
var remove = o.spy()
|
||||
var vnode = {tag: "div", attrs: {onbeforeremove: remove}, children: []}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
|
||||
|
||||
o(vnode.dom.onbeforeremove).equals(undefined)
|
||||
o(vnode.dom.attributes["onbeforeremove"]).equals(undefined)
|
||||
})
|
||||
|
|
@ -160,11 +160,11 @@ o.spec("onbeforeremove", function() {
|
|||
var remove = function(vnode, done) {done()}
|
||||
var vnode = {tag: "div", key: 1, attrs: {onbeforeremove: remove}}
|
||||
var updated = {tag: "div", key: 1, attrs: {onbeforeremove: remove}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(vnode.dom).notEquals(updated.dom)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -11,51 +11,51 @@ o.spec("onbeforeupdate", function() {
|
|||
root = $window.document.createElement("div")
|
||||
render = vdom($window).render
|
||||
})
|
||||
|
||||
|
||||
o("prevents update in element", function() {
|
||||
var onbeforeupdate = function() {return false}
|
||||
var vnode = {tag: "div", attrs: {id: "a", onbeforeupdate: onbeforeupdate}}
|
||||
var updated = {tag: "div", attrs: {id: "b", onbeforeupdate: onbeforeupdate}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(root.firstChild.attributes["id"].nodeValue).equals("a")
|
||||
})
|
||||
|
||||
|
||||
o("prevents update in text", function() {
|
||||
var onbeforeupdate = function() {return false}
|
||||
var vnode = {tag: "#", attrs: {onbeforeupdate: onbeforeupdate}, children: "a"}
|
||||
var updated = {tag: "#", attrs: {onbeforeupdate: onbeforeupdate}, children: "b"}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(root.firstChild.nodeValue).equals("a")
|
||||
})
|
||||
|
||||
|
||||
o("prevents update in html", function() {
|
||||
var onbeforeupdate = function() {return false}
|
||||
var vnode = {tag: "<", attrs: {onbeforeupdate: onbeforeupdate}, children: "a"}
|
||||
var updated = {tag: "<", attrs: {onbeforeupdate: onbeforeupdate}, children: "b"}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(root.firstChild.nodeValue).equals("a")
|
||||
})
|
||||
|
||||
|
||||
o("prevents update in fragment", function() {
|
||||
var onbeforeupdate = function() {return false}
|
||||
var vnode = {tag: "[", attrs: {onbeforeupdate: onbeforeupdate}, children: [{tag: "#", children: "a"}]}
|
||||
var updated = {tag: "[", attrs: {onbeforeupdate: onbeforeupdate}, children: [{tag: "#", children: "b"}]}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(root.firstChild.nodeValue).equals("a")
|
||||
})
|
||||
|
||||
|
||||
o("prevents update in component", function() {
|
||||
var component = {
|
||||
onbeforeupdate: function() {return false},
|
||||
|
|
@ -65,13 +65,13 @@ o.spec("onbeforeupdate", function() {
|
|||
}
|
||||
var vnode = {tag: component, children: [{tag: "#", children: "a"}]}
|
||||
var updated = {tag: component, children: [{tag: "#", children: "b"}]}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(root.firstChild.firstChild.nodeValue).equals("a")
|
||||
})
|
||||
|
||||
|
||||
o("prevents update if returning false in component and false in vnode", function() {
|
||||
var component = {
|
||||
onbeforeupdate: function() {return false},
|
||||
|
|
@ -81,13 +81,13 @@ o.spec("onbeforeupdate", function() {
|
|||
}
|
||||
var vnode = {tag: component, attrs: {id: "a", onbeforeupdate: function() {return false}}}
|
||||
var updated = {tag: component, attrs: {id: "b", onbeforeupdate: function() {return false}}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(root.firstChild.attributes["id"].nodeValue).equals("a")
|
||||
})
|
||||
|
||||
|
||||
o("does not prevent update if returning true in component and true in vnode", function() {
|
||||
var component = {
|
||||
onbeforeupdate: function() {return true},
|
||||
|
|
@ -97,13 +97,13 @@ o.spec("onbeforeupdate", function() {
|
|||
}
|
||||
var vnode = {tag: component, attrs: {id: "a", onbeforeupdate: function() {return true}}}
|
||||
var updated = {tag: component, attrs: {id: "b", onbeforeupdate: function() {return true}}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(root.firstChild.attributes["id"].nodeValue).equals("b")
|
||||
})
|
||||
|
||||
|
||||
o("does not prevent update if returning false in component but true in vnode", function() {
|
||||
var component = {
|
||||
onbeforeupdate: function() {return false},
|
||||
|
|
@ -113,13 +113,13 @@ o.spec("onbeforeupdate", function() {
|
|||
}
|
||||
var vnode = {tag: component, attrs: {id: "a", onbeforeupdate: function() {return true}}}
|
||||
var updated = {tag: component, attrs: {id: "b", onbeforeupdate: function() {return true}}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(root.firstChild.attributes["id"].nodeValue).equals("b")
|
||||
})
|
||||
|
||||
|
||||
o("does not prevent update if returning true in component but false in vnode", function() {
|
||||
var component = {
|
||||
onbeforeupdate: function() {return true},
|
||||
|
|
@ -129,24 +129,24 @@ o.spec("onbeforeupdate", function() {
|
|||
}
|
||||
var vnode = {tag: component, attrs: {id: "a", onbeforeupdate: function() {return false}}}
|
||||
var updated = {tag: component, attrs: {id: "b", onbeforeupdate: function() {return false}}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(root.firstChild.attributes["id"].nodeValue).equals("b")
|
||||
})
|
||||
|
||||
|
||||
o("does not prevent update if returning true", function() {
|
||||
var onbeforeupdate = function() {return true}
|
||||
var vnode = {tag: "div", attrs: {id: "a", onbeforeupdate: onbeforeupdate}}
|
||||
var updated = {tag: "div", attrs: {id: "b", onbeforeupdate: onbeforeupdate}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(root.firstChild.attributes["id"].nodeValue).equals("b")
|
||||
})
|
||||
|
||||
|
||||
o("does not prevent update if returning true from component", function() {
|
||||
var component = {
|
||||
onbeforeupdate: function() {return true},
|
||||
|
|
@ -156,34 +156,34 @@ o.spec("onbeforeupdate", function() {
|
|||
}
|
||||
var vnode = {tag: component, attrs: {id: "a"}}
|
||||
var updated = {tag: component, attrs: {id: "b"}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(root.firstChild.attributes["id"].nodeValue).equals("b")
|
||||
})
|
||||
|
||||
|
||||
o("accepts arguments for comparison", function() {
|
||||
var count = 0
|
||||
var vnode = {tag: "div", attrs: {id: "a", onbeforeupdate: onbeforeupdate}}
|
||||
var updated = {tag: "div", attrs: {id: "b", onbeforeupdate: onbeforeupdate}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
function onbeforeupdate(vnode, old) {
|
||||
count++
|
||||
|
||||
|
||||
o(old.attrs.id).equals("a")
|
||||
o(vnode.attrs.id).equals("b")
|
||||
|
||||
|
||||
return old.attrs.id !== vnode.attrs.id
|
||||
}
|
||||
|
||||
|
||||
o(count).equals(1)
|
||||
o(root.firstChild.attributes["id"].nodeValue).equals("b")
|
||||
})
|
||||
|
||||
|
||||
o("accepts arguments for comparison in component", function() {
|
||||
var component = {
|
||||
onbeforeupdate: onbeforeupdate,
|
||||
|
|
@ -194,38 +194,38 @@ o.spec("onbeforeupdate", function() {
|
|||
var count = 0
|
||||
var vnode = {tag: component, attrs: {id: "a"}}
|
||||
var updated = {tag: component, attrs: {id: "b"}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
function onbeforeupdate(vnode, old) {
|
||||
count++
|
||||
|
||||
|
||||
o(old.attrs.id).equals("a")
|
||||
o(vnode.attrs.id).equals("b")
|
||||
|
||||
|
||||
return old.attrs.id !== vnode.attrs.id
|
||||
}
|
||||
|
||||
|
||||
o(count).equals(1)
|
||||
o(root.firstChild.attributes["id"].nodeValue).equals("b")
|
||||
})
|
||||
|
||||
|
||||
o("is not called on creation", function() {
|
||||
var count = 0
|
||||
var vnode = {tag: "div", attrs: {id: "a", onbeforeupdate: onbeforeupdate}}
|
||||
var updated = {tag: "div", attrs: {id: "b", onbeforeupdate: onbeforeupdate}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
|
||||
|
||||
function onbeforeupdate(vnode, old) {
|
||||
count++
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
o(count).equals(0)
|
||||
})
|
||||
|
||||
|
||||
o("is not called on component creation", function() {
|
||||
var component = {
|
||||
onbeforeupdate: onbeforeupdate,
|
||||
|
|
@ -233,37 +233,37 @@ o.spec("onbeforeupdate", function() {
|
|||
return {tag: "div", attrs: vnode.attrs}
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
var count = 0
|
||||
var vnode = {tag: "div", attrs: {id: "a"}}
|
||||
var updated = {tag: "div", attrs: {id: "b"}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
|
||||
|
||||
function onbeforeupdate(vnode, old) {
|
||||
count++
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
o(count).equals(0)
|
||||
})
|
||||
|
||||
|
||||
o("is called only once on update", function() {
|
||||
var count = 0
|
||||
var vnode = {tag: "div", attrs: {id: "a", onbeforeupdate: onbeforeupdate}}
|
||||
var updated = {tag: "div", attrs: {id: "b", onbeforeupdate: onbeforeupdate}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
function onbeforeupdate(vnode, old) {
|
||||
count++
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
o(count).equals(1)
|
||||
})
|
||||
|
||||
|
||||
o("is called only once on component update", function() {
|
||||
var component = {
|
||||
onbeforeupdate: onbeforeupdate,
|
||||
|
|
@ -271,19 +271,19 @@ o.spec("onbeforeupdate", function() {
|
|||
return {tag: "div", attrs: vnode.attrs}
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
var count = 0
|
||||
var vnode = {tag: component, attrs: {id: "a"}}
|
||||
var updated = {tag: component, attrs: {id: "b"}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
function onbeforeupdate(vnode, old) {
|
||||
count++
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
o(count).equals(1)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -15,9 +15,9 @@ o.spec("oncreate", function() {
|
|||
o("calls oncreate when creating element", function() {
|
||||
var callback = o.spy()
|
||||
var vnode = {tag: "div", attrs: {oncreate: callback}, state: {}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
|
||||
|
||||
o(callback.callCount).equals(1)
|
||||
o(callback.this).equals(vnode.state)
|
||||
o(callback.args[0]).equals(vnode)
|
||||
|
|
@ -25,9 +25,9 @@ o.spec("oncreate", function() {
|
|||
o("calls oncreate when creating text", function() {
|
||||
var callback = o.spy()
|
||||
var vnode = {tag: "#", attrs: {oncreate: callback}, children: "a", state: {}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
|
||||
|
||||
o(callback.callCount).equals(1)
|
||||
o(callback.this).equals(vnode.state)
|
||||
o(callback.args[0]).equals(vnode)
|
||||
|
|
@ -35,9 +35,9 @@ o.spec("oncreate", function() {
|
|||
o("calls oncreate when creating fragment", function() {
|
||||
var callback = o.spy()
|
||||
var vnode = {tag: "[", attrs: {oncreate: callback}, children: [], state: {}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
|
||||
|
||||
o(callback.callCount).equals(1)
|
||||
o(callback.this).equals(vnode.state)
|
||||
o(callback.args[0]).equals(vnode)
|
||||
|
|
@ -45,9 +45,9 @@ o.spec("oncreate", function() {
|
|||
o("calls oncreate when creating html", function() {
|
||||
var callback = o.spy()
|
||||
var vnode = {tag: "<", attrs: {oncreate: callback}, children: "a", state: {}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
|
||||
|
||||
o(callback.callCount).equals(1)
|
||||
o(callback.this).equals(vnode.state)
|
||||
o(callback.args[0]).equals(vnode)
|
||||
|
|
@ -57,10 +57,10 @@ o.spec("oncreate", function() {
|
|||
var createA = o.spy()
|
||||
var vnode = {tag: "div", key: 1, attrs: {oncreate: createDiv}, state: {}}
|
||||
var updated = {tag: "a", key: 1, attrs: {oncreate: createA}, state: {}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(createDiv.callCount).equals(1)
|
||||
o(createDiv.this).equals(vnode.state)
|
||||
o(createDiv.args[0]).equals(vnode)
|
||||
|
|
@ -73,10 +73,10 @@ o.spec("oncreate", function() {
|
|||
var update = o.spy()
|
||||
var vnode = {tag: "div", attrs: {oncreate: create}, state: {}}
|
||||
var updated = {tag: "div", attrs: {oncreate: update}, state: {}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(create.callCount).equals(1)
|
||||
o(create.this).equals(vnode.state)
|
||||
o(create.args[0]).equals(vnode)
|
||||
|
|
@ -87,10 +87,10 @@ o.spec("oncreate", function() {
|
|||
var update = o.spy()
|
||||
var vnode = {tag: "div", attrs: {oncreate: create}, state: {}}
|
||||
var updated = {tag: "div", attrs: {oncreate: update, id: "a"}, state: {}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(create.callCount).equals(1)
|
||||
o(create.this).equals(vnode.state)
|
||||
o(create.args[0]).equals(vnode)
|
||||
|
|
@ -101,10 +101,10 @@ o.spec("oncreate", function() {
|
|||
var update = o.spy()
|
||||
var vnode = {tag: "div", attrs: {oncreate: create}, children: [{tag: "a"}], state: {}}
|
||||
var updated = {tag: "div", attrs: {oncreate: update}, children: [{tag: "b"}], state: {}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(create.callCount).equals(1)
|
||||
o(create.this).equals(vnode.state)
|
||||
o(create.args[0]).equals(vnode)
|
||||
|
|
@ -117,10 +117,10 @@ o.spec("oncreate", function() {
|
|||
var otherVnode = {tag: "a", key: 2}
|
||||
var updated = {tag: "div", key: 1, attrs: {oncreate: update}, state: {}}
|
||||
var otherUpdated = {tag: "a", key: 2}
|
||||
|
||||
|
||||
render(root, [vnode, otherVnode])
|
||||
render(root, [otherUpdated, updated])
|
||||
|
||||
|
||||
o(create.callCount).equals(1)
|
||||
o(create.this).equals(vnode.state)
|
||||
o(create.args[0]).equals(vnode)
|
||||
|
|
@ -130,10 +130,10 @@ o.spec("oncreate", function() {
|
|||
var create = o.spy()
|
||||
var update = o.spy()
|
||||
var vnode = {tag: "div", attrs: {oncreate: create}, state: {}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [])
|
||||
|
||||
|
||||
o(create.callCount).equals(1)
|
||||
o(create.this).equals(vnode.state)
|
||||
o(create.args[0]).equals(vnode)
|
||||
|
|
@ -143,11 +143,11 @@ o.spec("oncreate", function() {
|
|||
var update = o.spy()
|
||||
var vnode = {tag: "div", key: 1, attrs: {oncreate: create}, state: {}}
|
||||
var updated = {tag: "div", key: 1, attrs: {oncreate: update}, state: {}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(vnode.dom).notEquals(updated.dom)
|
||||
o(create.callCount).equals(1)
|
||||
o(create.this).equals(vnode.state)
|
||||
|
|
@ -162,10 +162,10 @@ o.spec("oncreate", function() {
|
|||
var callback = o.spy()
|
||||
var vnode = {tag: "div", attrs: {onupdate: create}, children: [], state: {}}
|
||||
var updated = {tag: "div", attrs: {onupdate: update}, children: [{tag: "a", attrs: {oncreate: callback}, state: {}}], state: {}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(create.callCount).equals(0)
|
||||
o(update.callCount).equals(1)
|
||||
o(update.this).equals(vnode.state)
|
||||
|
|
@ -181,12 +181,12 @@ o.spec("oncreate", function() {
|
|||
{tag: "b"}
|
||||
]}
|
||||
]}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
|
||||
|
||||
function create(vnode) {
|
||||
created = true
|
||||
|
||||
|
||||
o(vnode.dom.parentNode).notEquals(null)
|
||||
o(vnode.dom.childNodes.length).equals(1)
|
||||
}
|
||||
|
|
@ -195,9 +195,9 @@ o.spec("oncreate", function() {
|
|||
o("does not set oncreate as an event handler", function() {
|
||||
var create = o.spy()
|
||||
var vnode = {tag: "div", attrs: {oncreate: create}, children: []}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
|
||||
|
||||
o(vnode.dom.oncreate).equals(undefined)
|
||||
o(vnode.dom.attributes["oncreate"]).equals(undefined)
|
||||
})
|
||||
|
|
@ -206,11 +206,11 @@ o.spec("oncreate", function() {
|
|||
var vnodes = [{tag: "div", key: 1, attrs: {oncreate: create}}]
|
||||
var temp = []
|
||||
var updated = [{tag: "div", key: 1, attrs: {oncreate: create}}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, temp)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(create.callCount).equals(2)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -15,9 +15,9 @@ o.spec("oninit", function() {
|
|||
o("calls oninit when creating element", function() {
|
||||
var callback = o.spy()
|
||||
var vnode = {tag: "div", attrs: {oninit: callback}, state: {}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
|
||||
|
||||
o(callback.callCount).equals(1)
|
||||
o(callback.this).equals(vnode.state)
|
||||
o(callback.args[0]).equals(vnode)
|
||||
|
|
@ -25,9 +25,9 @@ o.spec("oninit", function() {
|
|||
o("calls oninit when creating text", function() {
|
||||
var callback = o.spy()
|
||||
var vnode = {tag: "#", attrs: {oninit: callback}, children: "a", state: {}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
|
||||
|
||||
o(callback.callCount).equals(1)
|
||||
o(callback.this).equals(vnode.state)
|
||||
o(callback.args[0]).equals(vnode)
|
||||
|
|
@ -35,9 +35,9 @@ o.spec("oninit", function() {
|
|||
o("calls oninit when creating fragment", function() {
|
||||
var callback = o.spy()
|
||||
var vnode = {tag: "[", attrs: {oninit: callback}, children: [], state: {}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
|
||||
|
||||
o(callback.callCount).equals(1)
|
||||
o(callback.this).equals(vnode.state)
|
||||
o(callback.args[0]).equals(vnode)
|
||||
|
|
@ -45,9 +45,9 @@ o.spec("oninit", function() {
|
|||
o("calls oninit when creating html", function() {
|
||||
var callback = o.spy()
|
||||
var vnode = {tag: "<", attrs: {oninit: callback}, children: "a", state: {}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
|
||||
|
||||
o(callback.callCount).equals(1)
|
||||
o(callback.this).equals(vnode.state)
|
||||
o(callback.args[0]).equals(vnode)
|
||||
|
|
@ -57,10 +57,10 @@ o.spec("oninit", function() {
|
|||
var createA = o.spy()
|
||||
var vnode = {tag: "div", key: 1, attrs: {oninit: createDiv}, state: {}}
|
||||
var updated = {tag: "a", key: 1, attrs: {oninit: createA}, state: {}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(createDiv.callCount).equals(1)
|
||||
o(createDiv.this).equals(vnode.state)
|
||||
o(createDiv.args[0]).equals(vnode)
|
||||
|
|
@ -73,10 +73,10 @@ o.spec("oninit", function() {
|
|||
var update = o.spy()
|
||||
var vnode = {tag: "div", attrs: {oninit: create}, state: {}}
|
||||
var updated = {tag: "div", attrs: {oninit: update}, state: {}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(create.callCount).equals(1)
|
||||
o(create.this).equals(vnode.state)
|
||||
o(create.args[0]).equals(vnode)
|
||||
|
|
@ -87,10 +87,10 @@ o.spec("oninit", function() {
|
|||
var update = o.spy()
|
||||
var vnode = {tag: "div", attrs: {oninit: create}, state: {}}
|
||||
var updated = {tag: "div", attrs: {oninit: update, id: "a"}, state: {}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(create.callCount).equals(1)
|
||||
o(create.this).equals(vnode.state)
|
||||
o(create.args[0]).equals(vnode)
|
||||
|
|
@ -101,10 +101,10 @@ o.spec("oninit", function() {
|
|||
var update = o.spy()
|
||||
var vnode = {tag: "div", attrs: {oninit: create}, children: [{tag: "a"}], state: {}}
|
||||
var updated = {tag: "div", attrs: {oninit: update}, children: [{tag: "b"}], state: {}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(create.callCount).equals(1)
|
||||
o(create.this).equals(vnode.state)
|
||||
o(create.args[0]).equals(vnode)
|
||||
|
|
@ -117,10 +117,10 @@ o.spec("oninit", function() {
|
|||
var otherVnode = {tag: "a", key: 2}
|
||||
var updated = {tag: "div", key: 1, attrs: {oninit: update}, state: {}}
|
||||
var otherUpdated = {tag: "a", key: 2}
|
||||
|
||||
|
||||
render(root, [vnode, otherVnode])
|
||||
render(root, [otherUpdated, updated])
|
||||
|
||||
|
||||
o(create.callCount).equals(1)
|
||||
o(create.this).equals(vnode.state)
|
||||
o(create.args[0]).equals(vnode)
|
||||
|
|
@ -130,10 +130,10 @@ o.spec("oninit", function() {
|
|||
var create = o.spy()
|
||||
var update = o.spy()
|
||||
var vnode = {tag: "div", attrs: {oninit: create}, state: {}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [])
|
||||
|
||||
|
||||
o(create.callCount).equals(1)
|
||||
o(create.this).equals(vnode.state)
|
||||
o(create.args[0]).equals(vnode)
|
||||
|
|
@ -143,11 +143,11 @@ o.spec("oninit", function() {
|
|||
var update = o.spy()
|
||||
var vnode = {tag: "div", key: 1, attrs: {oninit: create}, state: {}}
|
||||
var updated = {tag: "div", key: 1, attrs: {oninit: update}, state: {}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(vnode.dom).equals(updated.dom)
|
||||
o(create.callCount).equals(1)
|
||||
o(create.this).equals(vnode.state)
|
||||
|
|
@ -162,10 +162,10 @@ o.spec("oninit", function() {
|
|||
var callback = o.spy()
|
||||
var vnode = {tag: "div", attrs: {onupdate: create}, children: [], state: {}}
|
||||
var updated = {tag: "div", attrs: {onupdate: update}, children: [{tag: "a", attrs: {oninit: callback}, state: {}}], state: {}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(create.callCount).equals(0)
|
||||
o(update.callCount).equals(1)
|
||||
o(update.this).equals(vnode.state)
|
||||
|
|
@ -181,12 +181,12 @@ o.spec("oninit", function() {
|
|||
{tag: "b"}
|
||||
]}
|
||||
]}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
|
||||
|
||||
function create(vnode) {
|
||||
called = true
|
||||
|
||||
|
||||
o(vnode.dom).equals(undefined)
|
||||
o(root.childNodes.length).equals(0)
|
||||
}
|
||||
|
|
@ -195,9 +195,9 @@ o.spec("oninit", function() {
|
|||
o("does not set oninit as an event handler", function() {
|
||||
var create = o.spy()
|
||||
var vnode = {tag: "div", attrs: {oninit: create}, children: []}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
|
||||
|
||||
o(vnode.dom.oninit).equals(undefined)
|
||||
o(vnode.dom.attributes["oninit"]).equals(undefined)
|
||||
})
|
||||
|
|
@ -206,11 +206,11 @@ o.spec("oninit", function() {
|
|||
var vnodes = [{tag: "div", key: 1, attrs: {oninit: create}}]
|
||||
var temp = []
|
||||
var updated = [{tag: "div", key: 1, attrs: {oninit: create}}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, temp)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(create.callCount).equals(2)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -17,10 +17,10 @@ o.spec("onremove", function() {
|
|||
var update = o.spy()
|
||||
var vnode = {tag: "div", attrs: {onremove: create}}
|
||||
var updated = {tag: "div", attrs: {onremove: update}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(create.callCount).equals(0)
|
||||
})
|
||||
o("does not call onremove when updating", function() {
|
||||
|
|
@ -28,20 +28,20 @@ o.spec("onremove", function() {
|
|||
var update = o.spy()
|
||||
var vnode = {tag: "div", attrs: {onremove: create}}
|
||||
var updated = {tag: "div", attrs: {onremove: update}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(create.callCount).equals(0)
|
||||
o(update.callCount).equals(0)
|
||||
})
|
||||
o("calls onremove when removing element", function() {
|
||||
var remove = o.spy()
|
||||
var vnode = {tag: "div", attrs: {onremove: remove}, state: {}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [])
|
||||
|
||||
|
||||
o(remove.callCount).equals(1)
|
||||
o(remove.this).equals(vnode.state)
|
||||
o(remove.args[0]).equals(vnode)
|
||||
|
|
@ -49,10 +49,10 @@ o.spec("onremove", function() {
|
|||
o("calls onremove when removing text", function() {
|
||||
var remove = o.spy()
|
||||
var vnode = {tag: "#", attrs: {onremove: remove}, children: "a", state: {}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [])
|
||||
|
||||
|
||||
o(remove.callCount).equals(1)
|
||||
o(remove.this).equals(vnode.state)
|
||||
o(remove.args[0]).equals(vnode)
|
||||
|
|
@ -60,10 +60,10 @@ o.spec("onremove", function() {
|
|||
o("calls onremove when removing fragment", function() {
|
||||
var remove = o.spy()
|
||||
var vnode = {tag: "[", attrs: {onremove: remove}, children: [], state: {}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [])
|
||||
|
||||
|
||||
o(remove.callCount).equals(1)
|
||||
o(remove.this).equals(vnode.state)
|
||||
o(remove.args[0]).equals(vnode)
|
||||
|
|
@ -71,10 +71,10 @@ o.spec("onremove", function() {
|
|||
o("calls onremove when removing html", function() {
|
||||
var remove = o.spy()
|
||||
var vnode = {tag: "<", attrs: {onremove: remove}, children: "a", state: {}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [])
|
||||
|
||||
|
||||
o(remove.callCount).equals(1)
|
||||
o(remove.this).equals(vnode.state)
|
||||
o(remove.args[0]).equals(vnode)
|
||||
|
|
@ -82,9 +82,9 @@ o.spec("onremove", function() {
|
|||
o("does not set onremove as an event handler", function() {
|
||||
var remove = o.spy()
|
||||
var vnode = {tag: "div", attrs: {onremove: remove}, children: []}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
|
||||
|
||||
o(vnode.dom.onremove).equals(undefined)
|
||||
o(vnode.dom.attributes["onremove"]).equals(undefined)
|
||||
})
|
||||
|
|
@ -93,22 +93,22 @@ o.spec("onremove", function() {
|
|||
var vnodes = [{tag: "div", key: 1}]
|
||||
var temp = [{tag: "div", key: 2, attrs: {onremove: remove}}]
|
||||
var updated = [{tag: "div", key: 1}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, temp)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(remove.callCount).equals(1)
|
||||
})
|
||||
o("does not recycle when there's an onremove", function() {
|
||||
var remove = o.spy()
|
||||
var vnode = {tag: "div", key: 1, attrs: {onremove: remove}}
|
||||
var updated = {tag: "div", key: 1, attrs: {onremove: remove}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(vnode.dom).notEquals(updated.dom)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -17,10 +17,10 @@ o.spec("onupdate", function() {
|
|||
var update = o.spy()
|
||||
var vnode = {tag: "div", attrs: {onupdate: create}, state: {}}
|
||||
var updated = {tag: "div", attrs: {onupdate: update}, state: {}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(create.callCount).equals(0)
|
||||
o(update.callCount).equals(1)
|
||||
o(update.this).equals(vnode.state)
|
||||
|
|
@ -29,10 +29,10 @@ o.spec("onupdate", function() {
|
|||
o("does not call onupdate when removing element", function() {
|
||||
var create = o.spy()
|
||||
var vnode = {tag: "div", attrs: {onupdate: create}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [])
|
||||
|
||||
|
||||
o(create.callCount).equals(0)
|
||||
})
|
||||
o("does not call onupdate when replacing keyed element", function() {
|
||||
|
|
@ -42,7 +42,7 @@ o.spec("onupdate", function() {
|
|||
var updated = {tag: "a", key: 1, attrs: {onupdate: update}}
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(create.callCount).equals(0)
|
||||
o(update.callCount).equals(0)
|
||||
})
|
||||
|
|
@ -50,11 +50,11 @@ o.spec("onupdate", function() {
|
|||
var update = o.spy()
|
||||
var vnode = {tag: "div", key: 1, attrs: {onupdate: update}}
|
||||
var updated = {tag: "div", key: 1, attrs: {onupdate: update}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(vnode.dom).notEquals(updated.dom)
|
||||
})
|
||||
o("does not call old onupdate when removing the onupdate property in new vnode", function() {
|
||||
|
|
@ -62,10 +62,10 @@ o.spec("onupdate", function() {
|
|||
var update = o.spy()
|
||||
var vnode = {tag: "a", attrs: {onupdate: create}}
|
||||
var updated = {tag: "a"}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(create.callCount).equals(0)
|
||||
})
|
||||
o("calls onupdate when noop", function() {
|
||||
|
|
@ -73,10 +73,10 @@ o.spec("onupdate", function() {
|
|||
var update = o.spy()
|
||||
var vnode = {tag: "div", attrs: {onupdate: create}, state: {}}
|
||||
var updated = {tag: "div", attrs: {onupdate: update}, state: {}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(create.callCount).equals(0)
|
||||
o(update.callCount).equals(1)
|
||||
o(update.this).equals(vnode.state)
|
||||
|
|
@ -87,10 +87,10 @@ o.spec("onupdate", function() {
|
|||
var update = o.spy()
|
||||
var vnode = {tag: "div", attrs: {onupdate: create}, state: {}}
|
||||
var updated = {tag: "div", attrs: {onupdate: update, id: "a"}, state: {}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(create.callCount).equals(0)
|
||||
o(update.callCount).equals(1)
|
||||
o(update.this).equals(vnode.state)
|
||||
|
|
@ -101,10 +101,10 @@ o.spec("onupdate", function() {
|
|||
var update = o.spy()
|
||||
var vnode = {tag: "div", attrs: {onupdate: create}, children: [{tag: "a"}], state: {}}
|
||||
var updated = {tag: "div", attrs: {onupdate: update}, children: [{tag: "b"}], state: {}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(create.callCount).equals(0)
|
||||
o(update.callCount).equals(1)
|
||||
o(update.this).equals(vnode.state)
|
||||
|
|
@ -115,10 +115,10 @@ o.spec("onupdate", function() {
|
|||
var update = o.spy()
|
||||
var vnode = {tag: "#", attrs: {onupdate: create}, children: "a", state: {}}
|
||||
var updated = {tag: "#", attrs: {onupdate: update}, children: "a", state: {}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(create.callCount).equals(0)
|
||||
o(update.callCount).equals(1)
|
||||
o(update.this).equals(vnode.state)
|
||||
|
|
@ -129,10 +129,10 @@ o.spec("onupdate", function() {
|
|||
var update = o.spy()
|
||||
var vnode = {tag: "[", attrs: {onupdate: create}, children: [], state: {}}
|
||||
var updated = {tag: "[", attrs: {onupdate: update}, children: [], state: {}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(create.callCount).equals(0)
|
||||
o(update.callCount).equals(1)
|
||||
o(update.this).equals(vnode.state)
|
||||
|
|
@ -143,10 +143,10 @@ o.spec("onupdate", function() {
|
|||
var update = o.spy()
|
||||
var vnode = {tag: "<", attrs: {onupdate: create}, children: "a", state: {}}
|
||||
var updated = {tag: "<", attrs: {onupdate: update}, children: "a", state: {}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(create.callCount).equals(0)
|
||||
o(update.callCount).equals(1)
|
||||
o(update.this).equals(vnode.state)
|
||||
|
|
@ -164,13 +164,13 @@ o.spec("onupdate", function() {
|
|||
{tag: "b", attrs: {id: "33"}}
|
||||
]}
|
||||
]}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
function update(vnode) {
|
||||
called = true
|
||||
|
||||
|
||||
o(vnode.dom.parentNode.attributes["id"].nodeValue).equals("11")
|
||||
o(vnode.dom.attributes["id"].nodeValue).equals("22")
|
||||
o(vnode.dom.childNodes[0].attributes["id"].nodeValue).equals("33")
|
||||
|
|
@ -180,10 +180,10 @@ o.spec("onupdate", function() {
|
|||
o("does not set onupdate as an event handler", function() {
|
||||
var update = o.spy()
|
||||
var vnode = {tag: "div", attrs: {onupdate: update}, children: []}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
|
||||
|
||||
o(vnode.dom.onupdate).equals(undefined)
|
||||
o(vnode.dom.attributes["onupdate"]).equals(undefined)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -14,27 +14,27 @@ o.spec("textContent", function() {
|
|||
|
||||
o("ignores null", function() {
|
||||
var vnodes = [{tag: "a", text: null}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(1)
|
||||
o(vnodes[0].dom.childNodes.length).equals(0)
|
||||
o(vnodes[0].dom).equals(root.childNodes[0])
|
||||
})
|
||||
o("ignores undefined", function() {
|
||||
var vnodes = [{tag: "a", text: undefined}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(1)
|
||||
o(vnodes[0].dom.childNodes.length).equals(0)
|
||||
o(vnodes[0].dom).equals(root.childNodes[0])
|
||||
})
|
||||
o("creates string", function() {
|
||||
var vnodes = [{tag: "a", text: "a"}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(1)
|
||||
o(vnodes[0].dom.childNodes.length).equals(1)
|
||||
o(vnodes[0].dom.childNodes[0].nodeValue).equals("a")
|
||||
|
|
@ -42,9 +42,9 @@ o.spec("textContent", function() {
|
|||
})
|
||||
o("creates falsy string", function() {
|
||||
var vnodes = [{tag: "a", text: ""}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(1)
|
||||
o(vnodes[0].dom.childNodes.length).equals(1)
|
||||
o(vnodes[0].dom.childNodes[0].nodeValue).equals("")
|
||||
|
|
@ -52,9 +52,9 @@ o.spec("textContent", function() {
|
|||
})
|
||||
o("creates number", function() {
|
||||
var vnodes = [{tag: "a", text: 1}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(1)
|
||||
o(vnodes[0].dom.childNodes.length).equals(1)
|
||||
o(vnodes[0].dom.childNodes[0].nodeValue).equals("1")
|
||||
|
|
@ -62,9 +62,9 @@ o.spec("textContent", function() {
|
|||
})
|
||||
o("creates falsy number", function() {
|
||||
var vnodes = [{tag: "a", text: 0}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(1)
|
||||
o(vnodes[0].dom.childNodes.length).equals(1)
|
||||
o(vnodes[0].dom.childNodes[0].nodeValue).equals("0")
|
||||
|
|
@ -72,9 +72,9 @@ o.spec("textContent", function() {
|
|||
})
|
||||
o("creates boolean", function() {
|
||||
var vnodes = [{tag: "a", text: true}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(1)
|
||||
o(vnodes[0].dom.childNodes.length).equals(1)
|
||||
o(vnodes[0].dom.childNodes[0].nodeValue).equals("true")
|
||||
|
|
@ -82,9 +82,9 @@ o.spec("textContent", function() {
|
|||
})
|
||||
o("creates falsy boolean", function() {
|
||||
var vnodes = [{tag: "a", text: false}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(1)
|
||||
o(vnodes[0].dom.childNodes.length).equals(1)
|
||||
o(vnodes[0].dom.childNodes[0].nodeValue).equals("false")
|
||||
|
|
@ -93,10 +93,10 @@ o.spec("textContent", function() {
|
|||
o("updates to string", function() {
|
||||
var vnodes = [{tag: "a", text: "a"}]
|
||||
var updated = [{tag: "a", text: "b"}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(1)
|
||||
o(vnodes[0].dom.childNodes.length).equals(1)
|
||||
o(vnodes[0].dom.childNodes[0].nodeValue).equals("b")
|
||||
|
|
@ -105,10 +105,10 @@ o.spec("textContent", function() {
|
|||
o("updates to falsy string", function() {
|
||||
var vnodes = [{tag: "a", text: "a"}]
|
||||
var updated = [{tag: "a", text: ""}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(1)
|
||||
o(vnodes[0].dom.childNodes.length).equals(1)
|
||||
o(vnodes[0].dom.childNodes[0].nodeValue).equals("")
|
||||
|
|
@ -117,10 +117,10 @@ o.spec("textContent", function() {
|
|||
o("updates to number", function() {
|
||||
var vnodes = [{tag: "a", text: "a"}]
|
||||
var updated = [{tag: "a", text: 1}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(1)
|
||||
o(vnodes[0].dom.childNodes.length).equals(1)
|
||||
o(vnodes[0].dom.childNodes[0].nodeValue).equals("1")
|
||||
|
|
@ -129,10 +129,10 @@ o.spec("textContent", function() {
|
|||
o("updates to falsy number", function() {
|
||||
var vnodes = [{tag: "a", text: "a"}]
|
||||
var updated = [{tag: "a", text: 0}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(1)
|
||||
o(vnodes[0].dom.childNodes.length).equals(1)
|
||||
o(vnodes[0].dom.childNodes[0].nodeValue).equals("0")
|
||||
|
|
@ -141,10 +141,10 @@ o.spec("textContent", function() {
|
|||
o("updates to boolean", function() {
|
||||
var vnodes = [{tag: "a", text: "a"}]
|
||||
var updated = [{tag: "a", text: true}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(1)
|
||||
o(vnodes[0].dom.childNodes.length).equals(1)
|
||||
o(vnodes[0].dom.childNodes[0].nodeValue).equals("true")
|
||||
|
|
@ -153,10 +153,10 @@ o.spec("textContent", function() {
|
|||
o("updates to falsy boolean", function() {
|
||||
var vnodes = [{tag: "a", text: "a"}]
|
||||
var updated = [{tag: "a", text: false}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(1)
|
||||
o(vnodes[0].dom.childNodes.length).equals(1)
|
||||
o(vnodes[0].dom.childNodes[0].nodeValue).equals("false")
|
||||
|
|
@ -165,10 +165,10 @@ o.spec("textContent", function() {
|
|||
o("updates with typecasting", function() {
|
||||
var vnodes = [{tag: "a", text: "1"}]
|
||||
var updated = [{tag: "a", text: 1}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(1)
|
||||
o(vnodes[0].dom.childNodes.length).equals(1)
|
||||
o(vnodes[0].dom.childNodes[0].nodeValue).equals("1")
|
||||
|
|
@ -177,10 +177,10 @@ o.spec("textContent", function() {
|
|||
o("updates from without text to with text", function() {
|
||||
var vnodes = [{tag: "a"}]
|
||||
var updated = [{tag: "a", text: "b"}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(1)
|
||||
o(vnodes[0].dom.childNodes.length).equals(1)
|
||||
o(vnodes[0].dom.childNodes[0].nodeValue).equals("b")
|
||||
|
|
@ -189,12 +189,12 @@ o.spec("textContent", function() {
|
|||
o("updates from with text to without text", function() {
|
||||
var vnodes = [{tag: "a", text: "a"}]
|
||||
var updated = [{tag: "a"}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(1)
|
||||
o(vnodes[0].dom.childNodes.length).equals(0)
|
||||
o(updated[0].dom).equals(root.childNodes[0])
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -6,14 +6,14 @@ var trust = require("../../render/trust")
|
|||
o.spec("trust", function() {
|
||||
o("works with html", function() {
|
||||
var vnode = trust("<a></a>")
|
||||
|
||||
|
||||
o(vnode.tag).equals("<")
|
||||
o(vnode.children).equals("<a></a>")
|
||||
})
|
||||
o("works with text", function() {
|
||||
var vnode = trust("abc")
|
||||
|
||||
|
||||
o(vnode.tag).equals("<")
|
||||
o(vnode.children).equals("abc")
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -15,10 +15,10 @@ o.spec("updateElement", function() {
|
|||
o("updates attr", function() {
|
||||
var vnode = {tag: "a", attrs: {id: "b"}}
|
||||
var updated = {tag: "a", attrs: {id: "c"}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(updated.dom).equals(vnode.dom)
|
||||
o(updated.dom).equals(root.firstChild)
|
||||
o(updated.dom.attributes["id"].nodeValue).equals("c")
|
||||
|
|
@ -26,10 +26,10 @@ o.spec("updateElement", function() {
|
|||
o("adds attr", function() {
|
||||
var vnode = {tag: "a", attrs: {id: "b"}}
|
||||
var updated = {tag: "a", attrs: {id: "c", title: "d"}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(updated.dom).equals(vnode.dom)
|
||||
o(updated.dom).equals(root.firstChild)
|
||||
o(updated.dom.attributes["title"].nodeValue).equals("d")
|
||||
|
|
@ -37,10 +37,10 @@ o.spec("updateElement", function() {
|
|||
o("adds attr from empty attrs", function() {
|
||||
var vnode = {tag: "a"}
|
||||
var updated = {tag: "a", attrs: {title: "d"}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(updated.dom).equals(vnode.dom)
|
||||
o(updated.dom).equals(root.firstChild)
|
||||
o(updated.dom.attributes["title"].nodeValue).equals("d")
|
||||
|
|
@ -48,10 +48,10 @@ o.spec("updateElement", function() {
|
|||
o("removes attr", function() {
|
||||
var vnode = {tag: "a", attrs: {id: "b", title: "d"}}
|
||||
var updated = {tag: "a", attrs: {id: "c"}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(updated.dom).equals(vnode.dom)
|
||||
o(updated.dom).equals(root.firstChild)
|
||||
o("title" in updated.dom.attributes).equals(false)
|
||||
|
|
@ -59,145 +59,145 @@ o.spec("updateElement", function() {
|
|||
o("creates style object", function() {
|
||||
var vnode = {tag: "a", attrs: {}}
|
||||
var updated = {tag: "a", attrs: {style: {backgroundColor: "green"}}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(updated.dom.style.backgroundColor).equals("green")
|
||||
})
|
||||
o("creates style string", function() {
|
||||
var vnode = {tag: "a", attrs: {}}
|
||||
var updated = {tag: "a", attrs: {style: "background-color:green"}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(updated.dom.style.backgroundColor).equals("green")
|
||||
})
|
||||
o("updates style from object to object", function() {
|
||||
var vnode = {tag: "a", attrs: {style: {backgroundColor: "red"}}}
|
||||
var updated = {tag: "a", attrs: {style: {backgroundColor: "green"}}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(updated.dom.style.backgroundColor).equals("green")
|
||||
})
|
||||
o("updates style from object to string", function() {
|
||||
var vnode = {tag: "a", attrs: {style: {backgroundColor: "red"}}}
|
||||
var updated = {tag: "a", attrs: {style: "background-color:green;"}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(updated.dom.style.backgroundColor).equals("green")
|
||||
})
|
||||
o("handles noop style change when style is string", function() {
|
||||
var vnode = {tag: "a", attrs: {style: "background-color:green;"}}
|
||||
var updated = {tag: "a", attrs: {style: "background-color:green;"}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(updated.dom.style.backgroundColor).equals("green")
|
||||
})
|
||||
o("handles noop style change when style is object", function() {
|
||||
var vnode = {tag: "a", attrs: {style: {backgroundColor: "red"}}}
|
||||
var updated = {tag: "a", attrs: {style: {backgroundColor: "red"}}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(updated.dom.style.backgroundColor).equals("red")
|
||||
})
|
||||
o("updates style from string to object", function() {
|
||||
var vnode = {tag: "a", attrs: {style: "background-color:red;"}}
|
||||
var updated = {tag: "a", attrs: {style: {backgroundColor: "green"}}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(updated.dom.style.backgroundColor).equals("green")
|
||||
})
|
||||
o("updates style from string to string", function() {
|
||||
var vnode = {tag: "a", attrs: {style: "background-color:red;"}}
|
||||
var updated = {tag: "a", attrs: {style: "background-color:green;"}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(updated.dom.style.backgroundColor).equals("green")
|
||||
})
|
||||
o("removes style from object to object", function() {
|
||||
var vnode = {tag: "a", attrs: {style: {backgroundColor: "red", border: "1px solid red"}}}
|
||||
var updated = {tag: "a", attrs: {style: {backgroundColor: "red"}}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(updated.dom.style.backgroundColor).equals("red")
|
||||
o(updated.dom.style.border).equals("")
|
||||
})
|
||||
o("removes style from string to object", function() {
|
||||
var vnode = {tag: "a", attrs: {style: "background-color:red;border:1px solid red"}}
|
||||
var updated = {tag: "a", attrs: {style: {backgroundColor: "red"}}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(updated.dom.style.backgroundColor).equals("red")
|
||||
o(updated.dom.style.border).notEquals("1px solid red")
|
||||
})
|
||||
o("removes style from object to string", function() {
|
||||
var vnode = {tag: "a", attrs: {style: {backgroundColor: "red", border: "1px solid red"}}}
|
||||
var updated = {tag: "a", attrs: {style: "background-color:red"}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(updated.dom.style.backgroundColor).equals("red")
|
||||
o(updated.dom.style.border).equals("")
|
||||
})
|
||||
o("removes style from string to string", function() {
|
||||
var vnode = {tag: "a", attrs: {style: "background-color:red;border:1px solid red"}}
|
||||
var updated = {tag: "a", attrs: {style: "background-color:red"}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(updated.dom.style.backgroundColor).equals("red")
|
||||
o(updated.dom.style.border).equals("")
|
||||
})
|
||||
o("updates style when it's same object but mutated", function() {
|
||||
var style = {backgroundColor: "red", color: "gold"}
|
||||
var vnode = {tag: "a", attrs: {style: style}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
|
||||
|
||||
delete style.backgroundColor
|
||||
var updated = {tag: "a", attrs: {style: style}}
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(updated.dom.style.backgroundColor).equals("")
|
||||
o(updated.dom.style.color).equals("gold")
|
||||
})
|
||||
o("replaces el", function() {
|
||||
var vnode = {tag: "a"}
|
||||
var updated = {tag: "b"}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(updated.dom).equals(root.firstChild)
|
||||
o(updated.dom.nodeName).equals("B")
|
||||
})
|
||||
o("updates svg class", function() {
|
||||
var vnode = {tag: "svg", attrs: {className: "a"}}
|
||||
var updated = {tag: "svg", attrs: {className: "b"}}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(updated.dom.attributes["class"].nodeValue).equals("b")
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -15,20 +15,20 @@ o.spec("updateFragment", function() {
|
|||
o("updates fragment", function() {
|
||||
var vnode = {tag: "[", children: [{tag: "a"}]}
|
||||
var updated = {tag: "[", children: [{tag: "b"}]}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(updated.dom).equals(root.firstChild)
|
||||
o(updated.dom.nodeName).equals("B")
|
||||
})
|
||||
o("adds els", function() {
|
||||
var vnode = {tag: "[", children: []}
|
||||
var updated = {tag: "[", children: [{tag: "a"}, {tag: "b"}]}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(updated.dom).equals(root.firstChild)
|
||||
o(updated.domSize).equals(2)
|
||||
o(root.childNodes.length).equals(2)
|
||||
|
|
@ -38,10 +38,10 @@ o.spec("updateFragment", function() {
|
|||
o("removes els", function() {
|
||||
var vnode = {tag: "[", children: [{tag: "a"}, {tag: "b"}]}
|
||||
var updated = {tag: "[", children: []}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(updated.dom).equals(null)
|
||||
o(updated.domSize).equals(0)
|
||||
o(root.childNodes.length).equals(0)
|
||||
|
|
@ -49,20 +49,20 @@ o.spec("updateFragment", function() {
|
|||
o("updates from childless fragment", function() {
|
||||
var vnode = {tag: "["}
|
||||
var updated = {tag: "[", children: [{tag: "a"}]}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(updated.dom).equals(root.firstChild)
|
||||
o(updated.dom.nodeName).equals("A")
|
||||
})
|
||||
o("updates to childless fragment", function() {
|
||||
var vnode = {tag: "[", children: [{tag: "a"}]}
|
||||
var updated = {tag: "["}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(updated.dom).equals(null)
|
||||
o(root.childNodes.length).equals(0)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -15,20 +15,20 @@ o.spec("updateHTML", function() {
|
|||
o("updates html", function() {
|
||||
var vnode = {tag: "<", children: "a"}
|
||||
var updated = {tag: "<", children: "b"}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(updated.dom).equals(root.firstChild)
|
||||
o(updated.dom.nodeValue).equals("b")
|
||||
})
|
||||
o("adds html", function() {
|
||||
var vnode = {tag: "<", children: ""}
|
||||
var updated = {tag: "<", children: "<a></a><b></b>"}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(updated.domSize).equals(2)
|
||||
o(updated.dom).equals(root.firstChild)
|
||||
o(root.childNodes.length).equals(2)
|
||||
|
|
@ -38,10 +38,10 @@ o.spec("updateHTML", function() {
|
|||
o("removes html", function() {
|
||||
var vnode = {tag: "<", children: "<a></a><b></b>"}
|
||||
var updated = {tag: "<", children: ""}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(updated.dom).equals(null)
|
||||
o(updated.domSize).equals(0)
|
||||
o(root.childNodes.length).equals(0)
|
||||
|
|
|
|||
|
|
@ -15,10 +15,10 @@ o.spec("updateNodes", function() {
|
|||
o("handles el noop", function() {
|
||||
var vnodes = [{tag: "a", key: 1}, {tag: "b", key: 2}]
|
||||
var updated = [{tag: "a", key: 1}, {tag: "b", key: 2}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(2)
|
||||
o(updated[0].dom.nodeName).equals("A")
|
||||
o(updated[0].dom).equals(root.childNodes[0])
|
||||
|
|
@ -28,10 +28,10 @@ o.spec("updateNodes", function() {
|
|||
o("handles el noop without key", function() {
|
||||
var vnodes = [{tag: "a"}, {tag: "b"}]
|
||||
var updated = [{tag: "a"}, {tag: "b"}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(2)
|
||||
o(updated[0].dom.nodeName).equals("A")
|
||||
o(updated[0].dom).equals(root.childNodes[0])
|
||||
|
|
@ -41,10 +41,10 @@ o.spec("updateNodes", function() {
|
|||
o("handles text noop", function() {
|
||||
var vnodes = [{tag: "#", children: "a"}]
|
||||
var updated = [{tag: "#", children: "a"}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(1)
|
||||
o(updated[0].dom.nodeValue).equals("a")
|
||||
o(updated[0].dom).equals(root.childNodes[0])
|
||||
|
|
@ -52,10 +52,10 @@ o.spec("updateNodes", function() {
|
|||
o("handles text noop w/ type casting", function() {
|
||||
var vnodes = [{tag: "#", children: 1}]
|
||||
var updated = [{tag: "#", children: "1"}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(1)
|
||||
o(updated[0].dom.nodeValue).equals("1")
|
||||
o(updated[0].dom).equals(root.childNodes[0])
|
||||
|
|
@ -63,10 +63,10 @@ o.spec("updateNodes", function() {
|
|||
o("handles falsy text noop w/ type casting", function() {
|
||||
var vnodes = [{tag: "#", children: 0}]
|
||||
var updated = [{tag: "#", children: "0"}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(1)
|
||||
o(updated[0].dom.nodeValue).equals("0")
|
||||
o(updated[0].dom).equals(root.childNodes[0])
|
||||
|
|
@ -74,10 +74,10 @@ o.spec("updateNodes", function() {
|
|||
o("handles html noop", function() {
|
||||
var vnodes = [{tag: "<", children: "a"}]
|
||||
var updated = [{tag: "<", children: "a"}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(1)
|
||||
o(updated[0].dom.nodeValue).equals("a")
|
||||
o(updated[0].dom).equals(root.childNodes[0])
|
||||
|
|
@ -85,10 +85,10 @@ o.spec("updateNodes", function() {
|
|||
o("handles fragment noop", function() {
|
||||
var vnodes = [{tag: "[", children: [{tag: "a"}]}]
|
||||
var updated = [{tag: "[", children: [{tag: "a"}]}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(1)
|
||||
o(updated[0].dom.nodeName).equals("A")
|
||||
o(updated[0].dom).equals(root.childNodes[0])
|
||||
|
|
@ -96,10 +96,10 @@ o.spec("updateNodes", function() {
|
|||
o("handles fragment noop w/ text child", function() {
|
||||
var vnodes = [{tag: "[", children: [{tag: "#", children: "a"}]}]
|
||||
var updated = [{tag: "[", children: [{tag: "#", children: "a"}]}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(1)
|
||||
o(updated[0].dom.nodeValue).equals("a")
|
||||
o(updated[0].dom).equals(root.childNodes[0])
|
||||
|
|
@ -107,10 +107,10 @@ o.spec("updateNodes", function() {
|
|||
o("reverses els w/ even count", function() {
|
||||
var vnodes = [{tag: "a", key: 1}, {tag: "b", key: 2}, {tag: "i", key: 3}, {tag: "s", key: 4}]
|
||||
var updated = [{tag: "s", key: 4}, {tag: "i", key: 3}, {tag: "b", key: 2}, {tag: "a", key: 1}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(4)
|
||||
o(updated[0].dom.nodeName).equals("S")
|
||||
o(updated[0].dom).equals(root.childNodes[0])
|
||||
|
|
@ -124,10 +124,10 @@ o.spec("updateNodes", function() {
|
|||
o("reverses els w/ odd count", function() {
|
||||
var vnodes = [{tag: "a", key: 1}, {tag: "b", key: 2}, {tag: "i", key: 3}]
|
||||
var updated = [{tag: "i", key: 3}, {tag: "b", key: 2}, {tag: "a", key: 1}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(3)
|
||||
o(updated[0].dom.nodeName).equals("I")
|
||||
o(updated[0].dom).equals(root.childNodes[0])
|
||||
|
|
@ -139,10 +139,10 @@ o.spec("updateNodes", function() {
|
|||
o("creates el at start", function() {
|
||||
var vnodes = [{tag: "a", key: 1}]
|
||||
var updated = [{tag: "b", key: 2}, {tag: "a", key: 1}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(2)
|
||||
o(updated[0].dom.nodeName).equals("B")
|
||||
o(updated[0].dom).equals(root.childNodes[0])
|
||||
|
|
@ -152,10 +152,10 @@ o.spec("updateNodes", function() {
|
|||
o("creates el at end", function() {
|
||||
var vnodes = [{tag: "a", key: 1}]
|
||||
var updated = [{tag: "a", key: 1}, {tag: "b", key: 2}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(2)
|
||||
o(updated[0].dom.nodeName).equals("A")
|
||||
o(updated[0].dom).equals(root.childNodes[0])
|
||||
|
|
@ -165,10 +165,10 @@ o.spec("updateNodes", function() {
|
|||
o("creates el in middle", function() {
|
||||
var vnodes = [{tag: "a", key: 1}, {tag: "b", key: 2}]
|
||||
var updated = [{tag: "a", key: 1}, {tag: "i", key: 3}, {tag: "b", key: 2}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(updated[0].dom.nodeName).equals("A")
|
||||
o(updated[0].dom).equals(root.childNodes[0])
|
||||
o(updated[1].dom.nodeName).equals("I")
|
||||
|
|
@ -179,10 +179,10 @@ o.spec("updateNodes", function() {
|
|||
o("creates el while reversing", function() {
|
||||
var vnodes = [{tag: "a", key: 1}, {tag: "b", key: 2}]
|
||||
var updated = [{tag: "b", key: 2}, {tag: "i", key: 3}, {tag: "a", key: 1}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(3)
|
||||
o(updated[0].dom.nodeName).equals("B")
|
||||
o(updated[0].dom).equals(root.childNodes[0])
|
||||
|
|
@ -194,10 +194,10 @@ o.spec("updateNodes", function() {
|
|||
o("deletes el at start", function() {
|
||||
var vnodes = [{tag: "b", key: 2}, {tag: "a", key: 1}]
|
||||
var updated = [{tag: "a", key: 1}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(1)
|
||||
o(updated[0].dom.nodeName).equals("A")
|
||||
o(updated[0].dom).equals(root.childNodes[0])
|
||||
|
|
@ -205,10 +205,10 @@ o.spec("updateNodes", function() {
|
|||
o("deletes el at end", function() {
|
||||
var vnodes = [{tag: "a", key: 1}, {tag: "b", key: 2}]
|
||||
var updated = [{tag: "a", key: 1}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(1)
|
||||
o(updated[0].dom.nodeName).equals("A")
|
||||
o(updated[0].dom).equals(root.childNodes[0])
|
||||
|
|
@ -216,10 +216,10 @@ o.spec("updateNodes", function() {
|
|||
o("deletes el at middle", function() {
|
||||
var vnodes = [{tag: "a", key: 1}, {tag: "i", key: 3}, {tag: "b", key: 2}]
|
||||
var updated = [{tag: "a", key: 1}, {tag: "b", key: 2}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(2)
|
||||
o(updated[0].dom.nodeName).equals("A")
|
||||
o(updated[0].dom).equals(root.childNodes[0])
|
||||
|
|
@ -229,10 +229,10 @@ o.spec("updateNodes", function() {
|
|||
o("deletes el while reversing", function() {
|
||||
var vnodes = [{tag: "a", key: 1}, {tag: "i", key: 3}, {tag: "b", key: 2}]
|
||||
var updated = [{tag: "b", key: 2}, {tag: "a", key: 1}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(2)
|
||||
o(updated[0].dom.nodeName).equals("B")
|
||||
o(updated[0].dom).equals(root.childNodes[0])
|
||||
|
|
@ -242,10 +242,10 @@ o.spec("updateNodes", function() {
|
|||
o("creates, deletes, reverses els at same time", function() {
|
||||
var vnodes = [{tag: "a", key: 1}, {tag: "i", key: 3}, {tag: "b", key: 2}]
|
||||
var updated = [{tag: "b", key: 2}, {tag: "a", key: 1}, {tag: "s", key: 4}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(3)
|
||||
o(updated[0].dom.nodeName).equals("B")
|
||||
o(updated[0].dom).equals(root.childNodes[0])
|
||||
|
|
@ -257,10 +257,10 @@ o.spec("updateNodes", function() {
|
|||
o("adds to empty array followed by el", function() {
|
||||
var vnodes = [{tag: "[", key: 1, children: []}, {tag: "b", key: 2}]
|
||||
var updated = [{tag: "[", key: 1, children: [{tag: "a"}]}, {tag: "b", key: 2}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(2)
|
||||
o(updated[0].children[0].dom.nodeName).equals("A")
|
||||
o(updated[0].children[0].dom).equals(root.childNodes[0])
|
||||
|
|
@ -270,10 +270,10 @@ o.spec("updateNodes", function() {
|
|||
o("reverses followed by el", function() {
|
||||
var vnodes = [{tag: "[", key: 1, children: [{tag: "a", key: 2}, {tag: "b", key: 3}]}, {tag: "i", key: 4}]
|
||||
var updated = [{tag: "[", key: 1, children: [{tag: "b", key: 3}, {tag: "a", key: 2}]}, {tag: "i", key: 4}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(3)
|
||||
o(updated[0].children[0].dom.nodeName).equals("B")
|
||||
o(updated[0].children[0].dom).equals(root.childNodes[0])
|
||||
|
|
@ -285,10 +285,10 @@ o.spec("updateNodes", function() {
|
|||
o("updates empty array to html with same key", function() {
|
||||
var vnodes = [{tag: "[", key: 1, children: []}]
|
||||
var updated = [{tag: "<", key: 1, children: "<a></a><b></b>"}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(2)
|
||||
o(updated[0].dom.nodeName).equals("A")
|
||||
o(updated[0].dom).equals(root.childNodes[0])
|
||||
|
|
@ -299,10 +299,10 @@ o.spec("updateNodes", function() {
|
|||
o("updates empty html to array with same key", function() {
|
||||
var vnodes = [{tag: "<", key: 1, children: ""}]
|
||||
var updated = [{tag: "[", key: 1, children: [{tag: "a"}, {tag: "b"}]}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(2)
|
||||
o(updated[0].dom.nodeName).equals("A")
|
||||
o(updated[0].dom).equals(root.childNodes[0])
|
||||
|
|
@ -313,10 +313,10 @@ o.spec("updateNodes", function() {
|
|||
o("updates empty array to html without key", function() {
|
||||
var vnodes = [{tag: "[", children: []}]
|
||||
var updated = [{tag: "<", children: "<a></a><b></b>"}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(2)
|
||||
o(updated[0].dom.nodeName).equals("A")
|
||||
o(updated[0].dom).equals(root.childNodes[0])
|
||||
|
|
@ -327,10 +327,10 @@ o.spec("updateNodes", function() {
|
|||
o("updates empty html to array without key", function() {
|
||||
var vnodes = [{tag: "<", children: ""}]
|
||||
var updated = [{tag: "[", children: [{tag: "a"}, {tag: "b"}]}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(2)
|
||||
o(updated[0].dom.nodeName).equals("A")
|
||||
o(updated[0].dom).equals(root.childNodes[0])
|
||||
|
|
@ -341,10 +341,10 @@ o.spec("updateNodes", function() {
|
|||
o("updates array to html with same key", function() {
|
||||
var vnodes = [{tag: "[", key: 1, children: [{tag: "a"}, {tag: "b"}]}]
|
||||
var updated = [{tag: "<", key: 1, children: "<i></i><s></s>"}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(2)
|
||||
o(updated[0].dom.nodeName).equals("I")
|
||||
o(updated[0].dom).equals(root.childNodes[0])
|
||||
|
|
@ -355,10 +355,10 @@ o.spec("updateNodes", function() {
|
|||
o("updates html to array with same key", function() {
|
||||
var vnodes = [{tag: "<", key: 1, children: "<a></a><b></b>"}]
|
||||
var updated = [{tag: "[", key: 1, children: [{tag: "i"}, {tag: "s"}]}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(2)
|
||||
o(updated[0].dom.nodeName).equals("I")
|
||||
o(updated[0].dom).equals(root.childNodes[0])
|
||||
|
|
@ -369,10 +369,10 @@ o.spec("updateNodes", function() {
|
|||
o("updates array to html without key", function() {
|
||||
var vnodes = [{tag: "[", children: [{tag: "a"}, {tag: "b"}]}]
|
||||
var updated = [{tag: "<", children: "<i></i><s></s>"}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(2)
|
||||
o(updated[0].dom.nodeName).equals("I")
|
||||
o(updated[0].dom).equals(root.childNodes[0])
|
||||
|
|
@ -383,10 +383,10 @@ o.spec("updateNodes", function() {
|
|||
o("updates html to array without key", function() {
|
||||
var vnodes = [{tag: "<", children: "<a></a><b></b>"}]
|
||||
var updated = [{tag: "[", children: [{tag: "i"}, {tag: "s"}]}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(2)
|
||||
o(updated[0].dom.nodeName).equals("I")
|
||||
o(updated[0].dom).equals(root.childNodes[0])
|
||||
|
|
@ -397,10 +397,10 @@ o.spec("updateNodes", function() {
|
|||
o("updates empty array to html with same key followed by el", function() {
|
||||
var vnodes = [{tag: "[", key: 1, children: []}, {tag: "i", key: 2}]
|
||||
var updated = [{tag: "<", key: 1, children: "<a></a><b></b>"}, {tag: "i", key: 2}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(3)
|
||||
o(updated[0].dom.nodeName).equals("A")
|
||||
o(updated[0].dom).equals(root.childNodes[0])
|
||||
|
|
@ -413,10 +413,10 @@ o.spec("updateNodes", function() {
|
|||
o("updates empty html to array with same key followed by el", function() {
|
||||
var vnodes = [{tag: "[", key: 1, children: []}, {tag: "i", key: 2}]
|
||||
var updated = [{tag: "<", key: 1, children: "<a></a><b></b>"}, {tag: "i", key: 2}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(3)
|
||||
o(updated[0].dom.nodeName).equals("A")
|
||||
o(updated[0].dom).equals(root.childNodes[0])
|
||||
|
|
@ -429,10 +429,10 @@ o.spec("updateNodes", function() {
|
|||
o("populates array followed by null then el", function() {
|
||||
var vnodes = [{tag: "[", key: 1, children: []}, null, {tag: "i", key: 2}]
|
||||
var updated = [{tag: "[", key: 1, children: [{tag: "a"}, {tag: "b"}]}, null, {tag: "i", key: 2}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(3)
|
||||
o(updated[0].dom.nodeName).equals("A")
|
||||
o(updated[0].dom).equals(root.childNodes[0])
|
||||
|
|
@ -445,10 +445,10 @@ o.spec("updateNodes", function() {
|
|||
o("populates childless array followed by el", function() {
|
||||
var vnodes = [{tag: "[", key: 1}, {tag: "i", key: 2}]
|
||||
var updated = [{tag: "[", key: 1, children: [{tag: "a"}, {tag: "b"}]}, {tag: "i", key: 2}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(3)
|
||||
o(updated[0].dom.nodeName).equals("A")
|
||||
o(updated[0].dom).equals(root.childNodes[0])
|
||||
|
|
@ -461,10 +461,10 @@ o.spec("updateNodes", function() {
|
|||
o("populates childless array followed by null then el", function() {
|
||||
var vnodes = [{tag: "[", key: 1}, null, {tag: "i", key: 2}]
|
||||
var updated = [{tag: "[", key: 1, children: [{tag: "a"}, {tag: "b"}]}, null, {tag: "i", key: 2}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(3)
|
||||
o(updated[0].dom.nodeName).equals("A")
|
||||
o(updated[0].dom).equals(root.childNodes[0])
|
||||
|
|
@ -477,10 +477,10 @@ o.spec("updateNodes", function() {
|
|||
o("moves from end to start", function() {
|
||||
var vnodes = [{tag: "a", key: 1}, {tag: "b", key: 2}, {tag: "i", key: 3}, {tag: "s", key: 4}]
|
||||
var updated = [{tag: "s", key: 4}, {tag: "a", key: 1}, {tag: "b", key: 2}, {tag: "i", key: 3}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(4)
|
||||
o(updated[0].dom.nodeName).equals("S")
|
||||
o(updated[0].dom).equals(root.childNodes[0])
|
||||
|
|
@ -494,10 +494,10 @@ o.spec("updateNodes", function() {
|
|||
o("moves from start to end", function() {
|
||||
var vnodes = [{tag: "a", key: 1}, {tag: "b", key: 2}, {tag: "i", key: 3}, {tag: "s", key: 4}]
|
||||
var updated = [{tag: "b", key: 2}, {tag: "i", key: 3}, {tag: "s", key: 4}, {tag: "a", key: 1}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(4)
|
||||
o(updated[0].dom.nodeName).equals("B")
|
||||
o(updated[0].dom).equals(root.childNodes[0])
|
||||
|
|
@ -512,11 +512,11 @@ o.spec("updateNodes", function() {
|
|||
var vnodes = [{tag: "a", key: 1}, {tag: "b", key: 2}, {tag: "i", key: 3}, {tag: "s", key: 4}]
|
||||
var temp = []
|
||||
var updated = [{tag: "a", key: 1}, {tag: "b", key: 2}, {tag: "i", key: 3}, {tag: "s", key: 4}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, temp)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(4)
|
||||
o(updated[0].dom.nodeName).equals("A")
|
||||
o(updated[0].dom).equals(root.childNodes[0])
|
||||
|
|
@ -531,11 +531,11 @@ o.spec("updateNodes", function() {
|
|||
var vnodes = [{tag: "a", key: 1}, {tag: "b", key: 2}, {tag: "i", key: 3}, {tag: "s", key: 4}]
|
||||
var temp = []
|
||||
var updated = [{tag: "s", key: 4}, {tag: "i", key: 3}, {tag: "b", key: 2}, {tag: "a", key: 1}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, temp)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(4)
|
||||
o(updated[0].dom.nodeName).equals("S")
|
||||
o(updated[0].dom).equals(root.childNodes[0])
|
||||
|
|
@ -550,11 +550,11 @@ o.spec("updateNodes", function() {
|
|||
var vnodes = [{tag: "a", key: 1}, {tag: "b", key: 2}]
|
||||
var temp = []
|
||||
var updated = [{tag: "a", key: 1}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, temp)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(1)
|
||||
o(updated[0].dom.nodeName).equals("A")
|
||||
o(updated[0].dom).equals(root.childNodes[0])
|
||||
|
|
@ -563,11 +563,11 @@ o.spec("updateNodes", function() {
|
|||
var vnodes = [{tag: "a", key: 1}, {tag: "b", key: 2}]
|
||||
var temp = []
|
||||
var updated = [{tag: "a", key: 1}, {tag: "b", key: 2}, {tag: "i", key: 3}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, temp)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(3)
|
||||
o(updated[0].dom.nodeName).equals("A")
|
||||
o(updated[0].dom).equals(root.childNodes[0])
|
||||
|
|
@ -580,11 +580,11 @@ o.spec("updateNodes", function() {
|
|||
var vnodes = [{tag: "a", key: 1}, {tag: "b", key: 2}]
|
||||
var temp = []
|
||||
var updated = [{tag: "i", key: 3}, {tag: "s", key: 4}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, temp)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(2)
|
||||
o(updated[0].dom.nodeName).equals("I")
|
||||
o(updated[0].dom).equals(root.childNodes[0])
|
||||
|
|
@ -595,11 +595,11 @@ o.spec("updateNodes", function() {
|
|||
var vnodes = [{tag: "a", key: 1}, {tag: "b", key: 2}]
|
||||
var temp = []
|
||||
var updated = [{tag: "i", key: 3}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, temp)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(1)
|
||||
o(updated[0].dom.nodeName).equals("I")
|
||||
o(updated[0].dom).equals(root.childNodes[0])
|
||||
|
|
@ -608,11 +608,11 @@ o.spec("updateNodes", function() {
|
|||
var vnodes = [{tag: "a", key: 1}, {tag: "b", key: 2}]
|
||||
var temp = []
|
||||
var updated = [{tag: "i", key: 3}, {tag: "s", key: 4}, {tag: "div", key: 5}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, temp)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(3)
|
||||
o(updated[0].dom.nodeName).equals("I")
|
||||
o(updated[0].dom).equals(root.childNodes[0])
|
||||
|
|
@ -625,11 +625,11 @@ o.spec("updateNodes", function() {
|
|||
var vnodes = [{tag: "a", key: 1}, {tag: "b", key: 2}]
|
||||
var temp = []
|
||||
var updated = [{tag: "a", key: 1}, {tag: "s", key: 4}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, temp)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(2)
|
||||
o(updated[0].dom.nodeName).equals("A")
|
||||
o(updated[0].dom).equals(root.childNodes[0])
|
||||
|
|
@ -640,11 +640,11 @@ o.spec("updateNodes", function() {
|
|||
var vnodes = [{tag: "a", key: 1}, {tag: "b", key: 2}]
|
||||
var temp = []
|
||||
var updated = [{tag: "s", key: 4}, {tag: "a", key: 1}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, temp)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(2)
|
||||
o(updated[0].dom.nodeName).equals("S")
|
||||
o(updated[0].dom).equals(root.childNodes[0])
|
||||
|
|
@ -655,11 +655,11 @@ o.spec("updateNodes", function() {
|
|||
var vnodes = [{tag: "a", key: 1}, {tag: "b", key: 2}, {tag: "i", key: 3}]
|
||||
var temp = []
|
||||
var updated = [{tag: "a", key: 1}, {tag: "s", key: 4}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, temp)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(2)
|
||||
o(updated[0].dom.nodeName).equals("A")
|
||||
o(updated[0].dom).equals(root.childNodes[0])
|
||||
|
|
@ -670,11 +670,11 @@ o.spec("updateNodes", function() {
|
|||
var vnodes = [{tag: "a", key: 1}, {tag: "b", key: 2}, {tag: "i", key: 3}]
|
||||
var temp = []
|
||||
var updated = [{tag: "s", key: 4}, {tag: "a", key: 1}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, temp)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(2)
|
||||
o(updated[0].dom.nodeName).equals("S")
|
||||
o(updated[0].dom).equals(root.childNodes[0])
|
||||
|
|
@ -685,11 +685,11 @@ o.spec("updateNodes", function() {
|
|||
var vnodes = [{tag: "a", key: 1}, {tag: "b", key: 2}]
|
||||
var temp = []
|
||||
var updated = [{tag: "a", key: 1}, {tag: "i", key: 3}, {tag: "s", key: 4}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, temp)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(3)
|
||||
o(updated[0].dom.nodeName).equals("A")
|
||||
o(updated[0].dom).equals(root.childNodes[0])
|
||||
|
|
@ -702,11 +702,11 @@ o.spec("updateNodes", function() {
|
|||
var vnodes = [{tag: "a", key: 1}, {tag: "b", key: 2}]
|
||||
var temp = []
|
||||
var updated = [{tag: "s", key: 4}, {tag: "i", key: 3}, {tag: "a", key: 1}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, temp)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(3)
|
||||
o(updated[0].dom.nodeName).equals("S")
|
||||
o(updated[0].dom).equals(root.childNodes[0])
|
||||
|
|
@ -720,12 +720,12 @@ o.spec("updateNodes", function() {
|
|||
var temp1 = []
|
||||
var temp2 = [{tag: "a", key: 1, children: [{tag: "i", key: 3}, {tag: "s", key: 4}]}, {tag: "b", key: 2}]
|
||||
var updated = [{tag: "a", key: 1, children: [{tag: "s", key: 4}, {tag: "i", key: 3}]}, {tag: "b", key: 2}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, temp1)
|
||||
render(root, temp2)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(2)
|
||||
o(updated[0].dom.nodeName).equals("A")
|
||||
o(updated[0].dom).equals(root.childNodes[0])
|
||||
|
|
@ -739,11 +739,11 @@ o.spec("updateNodes", function() {
|
|||
var vnodes = [{tag: "a", key: 1, children: [{tag: "a", key: 3, children: [{tag: "a", key: 5}]}, {tag: "a", key: 4, children: [{tag: "a", key: 5}]}]}, {tag: "a", key: 2}]
|
||||
var temp = []
|
||||
var updated = [{tag: "a", key: 1, children: [{tag: "a", key: 3, children: [{tag: "a", key: 5}]}, {tag: "a", key: 4, children: [{tag: "a", key: 5}]}]}, {tag: "a", key: 2}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, temp)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(root.childNodes.length).equals(2)
|
||||
o(root.childNodes[0].childNodes.length).equals(2)
|
||||
o(root.childNodes[0].childNodes[0].childNodes.length).equals(1)
|
||||
|
|
@ -754,11 +754,11 @@ o.spec("updateNodes", function() {
|
|||
var vnodes = [{tag: "div", key: 1}]
|
||||
var temp = []
|
||||
var updated = [{tag: "div", key: 1}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, temp)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(vnodes[0].dom).equals(updated[0].dom)
|
||||
o(updated[0].dom.nodeName).equals("DIV")
|
||||
})
|
||||
|
|
@ -766,11 +766,11 @@ o.spec("updateNodes", function() {
|
|||
var vnodes = [{tag: "div", key: 1}]
|
||||
var temp = [{tag: "div"}]
|
||||
var updated = [{tag: "div", key: 1}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, temp)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(vnodes[0].dom).equals(updated[0].dom)
|
||||
o(updated[0].dom.nodeName).equals("DIV")
|
||||
})
|
||||
|
|
@ -778,11 +778,11 @@ o.spec("updateNodes", function() {
|
|||
var vnodes = [{tag: "div", children: [{tag: "a", key: 1}]}]
|
||||
var temp = [{tag: "div"}]
|
||||
var updated = [{tag: "div", children: [{tag: "a", key: 1}]}]
|
||||
|
||||
|
||||
render(root, vnodes)
|
||||
render(root, temp)
|
||||
render(root, updated)
|
||||
|
||||
|
||||
o(vnodes[0].dom.firstChild).equals(updated[0].dom.firstChild)
|
||||
o(updated[0].dom.firstChild.nodeName).equals("A")
|
||||
})
|
||||
|
|
|
|||
|
|
@ -15,10 +15,10 @@ o.spec("updateText", function() {
|
|||
o("updates to string", function() {
|
||||
var vnode = {tag: "#", children: "a"}
|
||||
var updated = {tag: "#", children: "b"}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(updated.dom).equals(vnode.dom)
|
||||
o(updated.dom).equals(root.firstChild)
|
||||
o(updated.dom.nodeValue).equals("b")
|
||||
|
|
@ -26,10 +26,10 @@ o.spec("updateText", function() {
|
|||
o("updates to falsy string", function() {
|
||||
var vnode = {tag: "#", children: "a"}
|
||||
var updated = {tag: "#", children: ""}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(updated.dom).equals(vnode.dom)
|
||||
o(updated.dom).equals(root.firstChild)
|
||||
o(updated.dom.nodeValue).equals("")
|
||||
|
|
@ -37,10 +37,10 @@ o.spec("updateText", function() {
|
|||
o("updates from falsy string", function() {
|
||||
var vnode = {tag: "#", children: ""}
|
||||
var updated = {tag: "#", children: "b"}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(updated.dom).equals(vnode.dom)
|
||||
o(updated.dom).equals(root.firstChild)
|
||||
o(updated.dom.nodeValue).equals("b")
|
||||
|
|
@ -48,10 +48,10 @@ o.spec("updateText", function() {
|
|||
o("updates to number", function() {
|
||||
var vnode = {tag: "#", children: "a"}
|
||||
var updated = {tag: "#", children: 1}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(updated.dom).equals(vnode.dom)
|
||||
o(updated.dom).equals(root.firstChild)
|
||||
o(updated.dom.nodeValue).equals("1")
|
||||
|
|
@ -59,10 +59,10 @@ o.spec("updateText", function() {
|
|||
o("updates to falsy number", function() {
|
||||
var vnode = {tag: "#", children: "a"}
|
||||
var updated = {tag: "#", children: 0}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(updated.dom).equals(vnode.dom)
|
||||
o(updated.dom).equals(root.firstChild)
|
||||
o(updated.dom.nodeValue).equals("0")
|
||||
|
|
@ -70,10 +70,10 @@ o.spec("updateText", function() {
|
|||
o("updates from falsy number", function() {
|
||||
var vnode = {tag: "#", children: 0}
|
||||
var updated = {tag: "#", children: "b"}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(updated.dom).equals(vnode.dom)
|
||||
o(updated.dom).equals(root.firstChild)
|
||||
o(updated.dom.nodeValue).equals("b")
|
||||
|
|
@ -81,10 +81,10 @@ o.spec("updateText", function() {
|
|||
o("updates to boolean", function() {
|
||||
var vnode = {tag: "#", children: "a"}
|
||||
var updated = {tag: "#", children: true}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(updated.dom).equals(vnode.dom)
|
||||
o(updated.dom).equals(root.firstChild)
|
||||
o(updated.dom.nodeValue).equals("true")
|
||||
|
|
@ -92,10 +92,10 @@ o.spec("updateText", function() {
|
|||
o("updates to falsy boolean", function() {
|
||||
var vnode = {tag: "#", children: "a"}
|
||||
var updated = {tag: "#", children: false}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(updated.dom).equals(vnode.dom)
|
||||
o(updated.dom).equals(root.firstChild)
|
||||
o(updated.dom.nodeValue).equals("false")
|
||||
|
|
@ -103,10 +103,10 @@ o.spec("updateText", function() {
|
|||
o("updates from falsy boolean", function() {
|
||||
var vnode = {tag: "#", children: false}
|
||||
var updated = {tag: "#", children: "b"}
|
||||
|
||||
|
||||
render(root, [vnode])
|
||||
render(root, [updated])
|
||||
|
||||
|
||||
o(updated.dom).equals(vnode.dom)
|
||||
o(updated.dom).equals(root.firstChild)
|
||||
o(updated.dom.nodeValue).equals("b")
|
||||
|
|
|
|||
|
|
@ -4,4 +4,4 @@ var Node = require("../render/node")
|
|||
|
||||
module.exports = function(html) {
|
||||
return Node("<", undefined, undefined, html, undefined, undefined)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue