"use strict" and other linty fixes

This commit is contained in:
Isiah Meadows 2017-03-02 07:26:52 -05:00
parent aaa6de784b
commit 1cc5fa5ba7
50 changed files with 463 additions and 478 deletions

View file

@ -12,19 +12,19 @@ o.spec("attributes", function() {
render = vdom($window).render
})
o.spec("customElements", function(){
o("when vnode is customElement, custom setAttribute called", function(){
var normal = [
{ tag: "input", attrs: { value: 'hello' } },
{ tag: "input", attrs: { value: 'hello' } },
{ tag: "input", attrs: { value: 'hello' } }
var normal = [
{tag: "input", attrs: {value: "hello"}},
{tag: "input", attrs: {value: "hello"}},
{tag: "input", attrs: {value: "hello"}}
]
var custom = [
{ tag: "custom-element", attrs: { custom: 'x' } },
{ tag: "input", attrs: { is: 'something-special', custom: 'x' } },
{ tag: "custom-element", attrs: { is: 'something-special', custom: 'x' } }
{tag: "custom-element", attrs: {custom: "x"}},
{tag: "input", attrs: {is: "something-special", custom: "x"}},
{tag: "custom-element", attrs: {is: "something-special", custom: "x"}}
]
var view = normal.concat(custom)
@ -43,8 +43,8 @@ o.spec("attributes", function() {
}
render(root, view)
o(spy.callCount).equals( custom.length )
o(spy.callCount).equals(custom.length)
})
})
@ -133,7 +133,7 @@ o.spec("attributes", function() {
})
o.spec("contenteditable throws on untrusted children", function() {
o("including text nodes", function() {
var div = {tag: "div", attrs: {contenteditable: true}, text: ''}
var div = {tag: "div", attrs: {contenteditable: true}, text: ""}
var succeeded = false
try {
@ -141,7 +141,7 @@ o.spec("attributes", function() {
succeeded = true
}
catch(e){}
catch(e){/* ignore */}
o(succeeded).equals(false)
})
@ -154,7 +154,7 @@ o.spec("attributes", function() {
succeeded = true
}
catch(e){}
catch(e){/* ignore */}
o(succeeded).equals(false)
})
@ -167,7 +167,7 @@ o.spec("attributes", function() {
succeeded = true
}
catch(e){}
catch(e){/* ignore */}
o(succeeded).equals(true)
})
@ -180,7 +180,7 @@ o.spec("attributes", function() {
succeeded = true
}
catch(e){}
catch(e){/* ignore */}
o(succeeded).equals(true)
})

View file

@ -63,7 +63,7 @@ o.spec("component", function() {
o("updates root from null", function() {
var visible = false
var component = createComponent({
view: function(vnode) {
view: function() {
return visible ? {tag: "div"} : null
}
})
@ -76,7 +76,7 @@ o.spec("component", function() {
o("updates root from primitive", function() {
var visible = false
var component = createComponent({
view: function(vnode) {
view: function() {
return visible ? {tag: "div"} : false
}
})
@ -89,7 +89,7 @@ o.spec("component", function() {
o("updates root to null", function() {
var visible = true
var component = createComponent({
view: function(vnode) {
view: function() {
return visible ? {tag: "div"} : null
}
})
@ -102,7 +102,7 @@ o.spec("component", function() {
o("updates root to primitive", function() {
var visible = true
var component = createComponent({
view: function(vnode) {
view: function() {
return visible ? {tag: "div"} : false
}
})
@ -114,7 +114,7 @@ o.spec("component", function() {
})
o("updates root from null to null", function() {
var component = createComponent({
view: function(vnode) {
view: function() {
return null
}
})
@ -125,7 +125,7 @@ o.spec("component", function() {
})
o("removes", function() {
var component = createComponent({
view: function(vnode) {
view: function() {
return {tag: "div"}
}
})
@ -138,7 +138,7 @@ o.spec("component", function() {
})
o("svg works when creating across component boundary", function() {
var component = createComponent({
view: function(vnode) {
view: function() {
return {tag: "g"}
}
})
@ -148,7 +148,7 @@ o.spec("component", function() {
})
o("svg works when updating across component boundary", function() {
var component = createComponent({
view: function(vnode) {
view: function() {
return {tag: "g"}
}
})
@ -161,7 +161,7 @@ o.spec("component", function() {
o.spec("return value", function() {
o("can return fragments", function() {
var component = createComponent({
view: function(vnode) {
view: function() {
return [
{tag: "label"},
{tag: "input"},
@ -176,7 +176,7 @@ o.spec("component", function() {
})
o("can return string", function() {
var component = createComponent({
view: function(vnode) {
view: function() {
return "a"
}
})
@ -187,7 +187,7 @@ o.spec("component", function() {
})
o("can return falsy string", function() {
var component = createComponent({
view: function(vnode) {
view: function() {
return ""
}
})
@ -198,7 +198,7 @@ o.spec("component", function() {
})
o("can return number", function() {
var component = createComponent({
view: function(vnode) {
view: function() {
return 1
}
})
@ -209,7 +209,7 @@ o.spec("component", function() {
})
o("can return falsy number", function() {
var component = createComponent({
view: function(vnode) {
view: function() {
return 0
}
})
@ -220,7 +220,7 @@ o.spec("component", function() {
})
o("can return boolean", function() {
var component = createComponent({
view: function(vnode) {
view: function() {
return true
}
})
@ -231,7 +231,7 @@ o.spec("component", function() {
})
o("can return falsy boolean", function() {
var component = createComponent({
view: function(vnode) {
view: function() {
return false
}
})
@ -242,7 +242,7 @@ o.spec("component", function() {
})
o("can return null", function() {
var component = createComponent({
view: function(vnode) {
view: function() {
return null
}
})
@ -252,7 +252,7 @@ o.spec("component", function() {
})
o("can return undefined", function() {
var component = createComponent({
view: function(vnode) {
view: function() {
return undefined
}
})
@ -278,7 +278,7 @@ o.spec("component", function() {
})
o("can update when returning fragments", function() {
var component = createComponent({
view: function(vnode) {
view: function() {
return [
{tag: "label"},
{tag: "input"},
@ -294,7 +294,7 @@ o.spec("component", function() {
})
o("can update when returning primitive", function() {
var component = createComponent({
view: function(vnode) {
view: function() {
return "a"
}
})
@ -306,7 +306,7 @@ o.spec("component", function() {
})
o("can update when returning null", function() {
var component = createComponent({
view: function(vnode) {
view: function() {
return null
}
})
@ -317,7 +317,7 @@ o.spec("component", function() {
})
o("can remove when returning fragments", function() {
var component = createComponent({
view: function(vnode) {
view: function() {
return [
{tag: "label"},
{tag: "input"},
@ -334,7 +334,7 @@ o.spec("component", function() {
})
o("can remove when returning primitive", function() {
var component = createComponent({
view: function(vnode) {
view: function() {
return "a"
}
})
@ -403,7 +403,7 @@ o.spec("component", function() {
viewCalled = true
return [{tag: "div", attrs: {id: "a"}, text: "b"}]
},
oninit: function(vnode) {
oninit: function() {
o(viewCalled).equals(false)
},
}
@ -646,7 +646,6 @@ o.spec("component", function() {
return {tag: "div"}
}
})
var update = o.spy()
var vnode = {tag: component, key: 1}
var updated = {tag: component, key: 1}
@ -659,7 +658,6 @@ o.spec("component", function() {
})
o.spec("state", function() {
o("initializes state", function() {
var called = 0
var data = {a: 1}
var component = createComponent(createComponent({
data: data,
@ -676,7 +674,6 @@ o.spec("component", function() {
}
})
o('state "copy" is shallow', function() {
var called = 0
var body = {a: 1}
var data = [body]
var component = createComponent(createComponent({
@ -701,7 +698,6 @@ o.spec("component", function() {
o.spec("POJO state", function() {
o("copies state", function() {
var called = 0
var data = {a: 1}
var component = {
data: data,

View file

@ -1,3 +1,4 @@
/* eslint-disable no-script-url */
"use strict"
var o = require("../../ospec/ospec")

View file

@ -1,3 +1,5 @@
"use strict"
var o = require("../../ospec/ospec")
var m = require("../../render/hyperscript")

View file

@ -17,7 +17,6 @@ o.spec("onbeforeremove", function() {
o("does not call onbeforeremove when creating", function() {
var create = o.spy()
var update = o.spy()
var vnode = {tag: "div", attrs: {onbeforeremove: create}}
render(root, [vnode])
@ -142,7 +141,7 @@ o.spec("onbeforeremove", function() {
o(vnode.dom.attributes["onbeforeremove"]).equals(undefined)
})
o("does not recycle when there's an onbeforeremove", function() {
var remove = function(vnode) {}
var remove = function() {}
var vnode = {tag: "div", key: 1, attrs: {onbeforeremove: remove}}
var updated = {tag: "div", key: 1, attrs: {onbeforeremove: remove}}
@ -153,7 +152,7 @@ o.spec("onbeforeremove", function() {
o(vnode.dom).notEquals(updated.dom)
})
o("does not leave elements out of order during removal", function(done) {
var remove = function(vnode) {return Promise.resolve()}
var remove = function() {return Promise.resolve()}
var vnodes = [{tag: "div", key: 1, attrs: {onbeforeremove: remove}, text: "1"}, {tag: "div", key: 2, attrs: {onbeforeremove: remove}, text: "2"}]
var updated = {tag: "div", key: 2, attrs: {onbeforeremove: remove}, text: "2"}

View file

@ -92,11 +92,10 @@ o.spec("onbeforeupdate", function() {
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) {
function onbeforeupdate() {
count++
return true
}
@ -112,7 +111,7 @@ o.spec("onbeforeupdate", function() {
render(root, [vnode])
render(root, [updated])
function onbeforeupdate(vnode, old) {
function onbeforeupdate() {
count++
return true
}
@ -248,7 +247,7 @@ o.spec("onbeforeupdate", function() {
})
o("is not called on component creation", function() {
var component = createComponent({
createComponent({
onbeforeupdate: onbeforeupdate,
view: function(vnode) {
return {tag: "div", attrs: vnode.attrs}
@ -257,11 +256,10 @@ o.spec("onbeforeupdate", function() {
var count = 0
var vnode = {tag: "div", attrs: {id: "a"}}
var updated = {tag: "div", attrs: {id: "b"}}
render(root, [vnode])
function onbeforeupdate(vnode, old) {
function onbeforeupdate() {
count++
return true
}
@ -284,7 +282,7 @@ o.spec("onbeforeupdate", function() {
render(root, [vnode])
render(root, [updated])
function onbeforeupdate(vnode, old) {
function onbeforeupdate() {
count++
return true
}
@ -293,4 +291,4 @@ o.spec("onbeforeupdate", function() {
})
})
})
})
})

View file

@ -128,7 +128,6 @@ o.spec("oncreate", function() {
})
o("does not call oncreate when removing", function() {
var create = o.spy()
var update = o.spy()
var vnode = {tag: "div", attrs: {oncreate: create}, state: {}}
render(root, [vnode])

View file

@ -128,7 +128,6 @@ o.spec("oninit", function() {
})
o("does not call oninit when removing", function() {
var create = o.spy()
var update = o.spy()
var vnode = {tag: "div", attrs: {oninit: create}, state: {}}
render(root, [vnode])

View file

@ -59,7 +59,6 @@ o.spec("onupdate", function() {
})
o("does not call old onupdate when removing the onupdate property in new vnode", function() {
var create = o.spy()
var update = o.spy()
var vnode = {tag: "a", attrs: {onupdate: create}}
var updated = {tag: "a"}

View file

@ -1,7 +1,6 @@
"use strict"
var o = require("../../ospec/ospec")
var components = require("../../test-utils/components")
var domMock = require("../../test-utils/domMock")
var vdom = require("../../render/render")
@ -124,7 +123,7 @@ o.spec("render", function() {
var onbeforeupdate = o.spy()
function A() {
return {
view: function(vnode) {throw new Error("error")},
view: function() {throw new Error("error")},
oninit: oninit,
onbeforeupdate: onbeforeupdate
}
@ -143,11 +142,11 @@ o.spec("render", function() {
o(onbeforeupdate.callCount).equals(0)
})
o("does not try to re-initialize a closure component whose oninit has thrown", function() {
var oninit = o.spy(function(vnode) {throw new Error("error")})
var oninit = o.spy(function() {throw new Error("error")})
var onbeforeupdate = o.spy()
function A() {
return {
view: function(vnode) {},
view: function() {},
oninit: oninit,
onbeforeupdate: onbeforeupdate
}

View file

@ -213,10 +213,10 @@ o.spec("updateElement", function() {
})
o("updates svg child", function() {
var vnode = {tag: "svg", children: [{
tag: 'circle'
tag: "circle"
}]}
var updated = {tag: "svg", children: [{
tag: 'line'
tag: "line"
}]}
render(root, [vnode])
@ -235,7 +235,7 @@ o.spec("updateElement", function() {
render(root, [vnode])
var c = vnode.dom
o(root.childNodes.length).equals(1)
o(a).equals(c)
})
@ -254,7 +254,7 @@ o.spec("updateElement", function() {
render(root, [e, b, f])
var y = root.childNodes[1]
o(root.childNodes.length).equals(3)
o(x).equals(y)
})

View file

@ -727,7 +727,7 @@ o.spec("updateNodes", function() {
})
o("change type, position and length", function() {
var vnodes = {tag: "div", children: [
undefined,
undefined,
{tag: "#", children: "a"}
]}
var updated = {tag: "div", children: [
@ -738,7 +738,7 @@ o.spec("updateNodes", function() {
render(root, vnodes)
render(root, updated)
o(root.firstChild.childNodes.length).equals(1)
})
o("removes then recreates then reverses children", function() {
@ -864,13 +864,13 @@ o.spec("updateNodes", function() {
var vnodes = [{tag: "div"}, {tag: "a", attrs: {oncreate: create, onupdate: update, onremove: remove}}]
var temp = [null, {tag: "a", attrs: {oncreate: create, onupdate: update, onremove: remove}}]
var updated = [{tag: "div"}, {tag: "a", attrs: {oncreate: create, onupdate: update, onremove: remove}}]
render(root, vnodes)
var before = vnodes[1].dom
render(root, temp)
render(root, updated)
var after = updated[1].dom
o(before).equals(after)
o(create.callCount).equals(1)
o(update.callCount).equals(2)
@ -883,13 +883,13 @@ o.spec("updateNodes", function() {
var vnodes = [{tag: "b"}, {tag: "div"}, {tag: "a", attrs: {oncreate: create, onupdate: update, onremove: remove}}]
var temp = [{tag: "b"}, null, {tag: "a", attrs: {oncreate: create, onupdate: update, onremove: remove}}]
var updated = [{tag: "b"}, {tag: "div"}, {tag: "a", attrs: {oncreate: create, onupdate: update, onremove: remove}}]
render(root, vnodes)
var before = vnodes[2].dom
render(root, temp)
render(root, updated)
var after = updated[2].dom
o(before).equals(after)
o(create.callCount).equals(1)
o(update.callCount).equals(2)
@ -898,11 +898,10 @@ o.spec("updateNodes", function() {
o("node is recreated if key changes to undefined", function () {
var vnode = {tag: "b", key: 1}
var updated = {tag: "b"}
render(root, vnode)
var dom = vnode.dom
render(root, updated)
o(vnode.dom).notEquals(updated.dom)
})
components.forEach(function(cmp){
@ -943,4 +942,4 @@ o.spec("updateNodes", function() {
})
})
})
})
})