Merge 'origin/patch-2', remove trailing commas
This commit is contained in:
parent
e0f51db618
commit
0b173deed7
19 changed files with 380 additions and 384 deletions
|
|
@ -53,7 +53,6 @@
|
|||
"block-spacing": 2,
|
||||
"brace-style": [2, "1tbs", {"allowSingleLine": true}],
|
||||
"camelcase": 2,
|
||||
"comma-dangle": [2, "always-multiline"],
|
||||
"comma-spacing": 2,
|
||||
"comma-style": 2,
|
||||
"consistent-this": [2, "self"],
|
||||
|
|
|
|||
|
|
@ -120,8 +120,8 @@ for (var i = 0; i < CARD_DECK_SIZE; i++) {
|
|||
|
||||
// Also good
|
||||
function toFastProperties(obj) {
|
||||
// Bluebird's toFastProperties hack. Forces V8 to optimize object as prototype,
|
||||
// significantly speeding up property access.
|
||||
// Bluebird's toFastProperties hack. Forces V8 to optimize object as
|
||||
// prototype, significantly speeding up property access.
|
||||
|
||||
/* eslint-disable no-eval */
|
||||
function C() {}
|
||||
|
|
@ -362,7 +362,7 @@ var object = {
|
|||
foo: 1,
|
||||
bar: 2,
|
||||
baz: 3,
|
||||
quux: "string",
|
||||
quux: "string"
|
||||
}
|
||||
|
||||
// Bad
|
||||
|
|
@ -373,7 +373,7 @@ var object = {
|
|||
foo: 1,
|
||||
bar: 2,
|
||||
baz: 3,
|
||||
quux: "string",
|
||||
quux: "string"
|
||||
|
||||
}
|
||||
```
|
||||
|
|
@ -402,7 +402,7 @@ var object = {
|
|||
foo: 1,
|
||||
bar: 2,
|
||||
baz: 3,
|
||||
quux: "string",
|
||||
quux: "string"
|
||||
}
|
||||
|
||||
// Bad
|
||||
|
|
@ -413,28 +413,25 @@ Prefer plain objects over `new function () {}`, but if you feel the latter is be
|
|||
|
||||
### Comma placement
|
||||
|
||||
Commas come last. Also, use trailing commas if the object takes multiple lines.
|
||||
Commas come last. Don't use trailing commas
|
||||
|
||||
```js
|
||||
// Good
|
||||
var object = {
|
||||
foo: 1,
|
||||
bar: 2,
|
||||
bar: 2
|
||||
}
|
||||
|
||||
// Bad
|
||||
var object = {
|
||||
foo: 1,
|
||||
bar: 2 // No trailing comma
|
||||
bar: 2, // Trailing comma
|
||||
}
|
||||
|
||||
var object = {
|
||||
foo: 1
|
||||
, bar: 2 // Comma first
|
||||
}
|
||||
|
||||
// Also bad
|
||||
var object = {foo: 1,}
|
||||
```
|
||||
|
||||
### Member access
|
||||
|
|
@ -461,23 +458,23 @@ Quote properties when needed. Never quote valid identifiers. This may lead to so
|
|||
// Good
|
||||
var object = {
|
||||
foo: 1,
|
||||
bar: 2,
|
||||
bar: 2
|
||||
}
|
||||
|
||||
var object = {
|
||||
foo: 1,
|
||||
"non-identifier": 2,
|
||||
"non-identifier": 2
|
||||
}
|
||||
|
||||
// Bad
|
||||
var object = {
|
||||
"foo": 1,
|
||||
"bar": 2,
|
||||
"bar": 2
|
||||
}
|
||||
|
||||
var object = {
|
||||
"foo": 1,
|
||||
"non-identifier": 2,
|
||||
"non-identifier": 2
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
|||
114
Gruntfile.js
114
Gruntfile.js
|
|
@ -22,7 +22,7 @@ module.exports = function (grunt) { // eslint-disable-line
|
|||
"refactoring",
|
||||
"routing",
|
||||
"tools",
|
||||
"web-services",
|
||||
"web-services"
|
||||
]
|
||||
|
||||
var api = [
|
||||
|
|
@ -43,7 +43,7 @@ module.exports = function (grunt) { // eslint-disable-line
|
|||
"mithril.sync",
|
||||
"mithril.trust",
|
||||
"mithril.withAttr",
|
||||
"mithril.xhr",
|
||||
"mithril.xhr"
|
||||
]
|
||||
|
||||
var md2htmlTasks = {}
|
||||
|
|
@ -60,12 +60,12 @@ module.exports = function (grunt) { // eslint-disable-line
|
|||
md2htmlTasks[name] = {
|
||||
options: {
|
||||
layout: inputFolder + "/layout/" + layout + ".html",
|
||||
templateData: {topic: title},
|
||||
templateData: {topic: title}
|
||||
},
|
||||
files: [{
|
||||
src: [src],
|
||||
dest: tempFolder + "/" + name + ".html",
|
||||
}],
|
||||
dest: tempFolder + "/" + name + ".html"
|
||||
}]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
@ -80,7 +80,7 @@ module.exports = function (grunt) { // eslint-disable-line
|
|||
eslint: {
|
||||
options: {
|
||||
extensions: [".js"],
|
||||
fix: true,
|
||||
fix: true
|
||||
},
|
||||
all: [
|
||||
"**/*.js",
|
||||
|
|
@ -89,17 +89,17 @@ module.exports = function (grunt) { // eslint-disable-line
|
|||
"!archive/**",
|
||||
"!deploy/**",
|
||||
"!mithril.closure-compiler-externs.js",
|
||||
"!docs/layout/lib/**",
|
||||
],
|
||||
"!docs/layout/lib/**"
|
||||
]
|
||||
},
|
||||
|
||||
mocha_phantomjs: { // eslint-disable-line camelcase
|
||||
test: {
|
||||
src: ["test/index.html"],
|
||||
options: {
|
||||
reporter: "dot",
|
||||
},
|
||||
},
|
||||
reporter: "dot"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
md2html: md2htmlTasks,
|
||||
|
|
@ -112,11 +112,11 @@ module.exports = function (grunt) { // eslint-disable-line
|
|||
pkg.homepage,
|
||||
"(c) 2014-" + currentYear + " " + pkg.author.name,
|
||||
"License: " + pkg.license,
|
||||
"*/",
|
||||
"*/"
|
||||
].join("\n"),
|
||||
sourceMap: true,
|
||||
sourceMap: true
|
||||
},
|
||||
mithril: {src: "mithril.js", dest: "mithril.min.js"},
|
||||
mithril: {src: "mithril.js", dest: "mithril.min.js"}
|
||||
},
|
||||
|
||||
zip: {
|
||||
|
|
@ -125,10 +125,10 @@ module.exports = function (grunt) { // eslint-disable-line
|
|||
src: [
|
||||
currentVersionArchiveFolder + "/mithril.min.js",
|
||||
currentVersionArchiveFolder + "/mithril.min.js.map",
|
||||
currentVersionArchiveFolder + "/mithril.js",
|
||||
currentVersionArchiveFolder + "/mithril.js"
|
||||
],
|
||||
dest: currentVersionArchiveFolder + "/mithril.min.zip",
|
||||
},
|
||||
dest: currentVersionArchiveFolder + "/mithril.min.zip"
|
||||
}
|
||||
},
|
||||
|
||||
replace: {
|
||||
|
|
@ -136,105 +136,105 @@ module.exports = function (grunt) { // eslint-disable-line
|
|||
force: true,
|
||||
patterns: [
|
||||
{match: /\.md/g, replacement: ".html"},
|
||||
{match: /\$version/g, replacement: pkg.version},
|
||||
],
|
||||
{match: /\$version/g, replacement: pkg.version}
|
||||
]
|
||||
},
|
||||
|
||||
links: {
|
||||
expand: true,
|
||||
flatten: true,
|
||||
src: [tempFolder + "/**/*.html"],
|
||||
dest: currentVersionArchiveFolder + "/",
|
||||
dest: currentVersionArchiveFolder + "/"
|
||||
},
|
||||
|
||||
index: {
|
||||
src: inputFolder + "/layout/index.html",
|
||||
dest: currentVersionArchiveFolder + "/index.html",
|
||||
dest: currentVersionArchiveFolder + "/index.html"
|
||||
},
|
||||
|
||||
commonjs: {
|
||||
expand: true,
|
||||
flatten: true,
|
||||
src: [inputFolder + "/layout/*.json"],
|
||||
dest: currentVersionArchiveFolder,
|
||||
dest: currentVersionArchiveFolder
|
||||
},
|
||||
|
||||
cdnjs: {
|
||||
src: "deploy/cdnjs-package.json",
|
||||
dest: "../cdnjs/ajax/libs/mithril/package.json",
|
||||
},
|
||||
dest: "../cdnjs/ajax/libs/mithril/package.json"
|
||||
}
|
||||
},
|
||||
|
||||
copy: {
|
||||
style: {
|
||||
src: inputFolder + "/layout/style.css",
|
||||
dest: currentVersionArchiveFolder + "/style.css",
|
||||
dest: currentVersionArchiveFolder + "/style.css"
|
||||
},
|
||||
|
||||
pages: {
|
||||
src: inputFolder + "/layout/pages.json",
|
||||
dest: currentVersionArchiveFolder + "/pages.json",
|
||||
dest: currentVersionArchiveFolder + "/pages.json"
|
||||
},
|
||||
|
||||
lib: {
|
||||
expand: true,
|
||||
cwd: inputFolder + "/layout/lib/",
|
||||
src: "./**",
|
||||
dest: currentVersionArchiveFolder + "/lib/",
|
||||
dest: currentVersionArchiveFolder + "/lib/"
|
||||
},
|
||||
|
||||
tools: {
|
||||
expand: true,
|
||||
cwd: inputFolder + "/layout/tools/",
|
||||
src: "./**",
|
||||
dest: currentVersionArchiveFolder + "/tools/",
|
||||
dest: currentVersionArchiveFolder + "/tools/"
|
||||
},
|
||||
|
||||
comparisons: {
|
||||
expand: true,
|
||||
cwd: inputFolder + "/layout/comparisons/",
|
||||
src: "./**",
|
||||
dest: currentVersionArchiveFolder + "/comparisons/",
|
||||
dest: currentVersionArchiveFolder + "/comparisons/"
|
||||
},
|
||||
|
||||
unminified: {
|
||||
src: "mithril.js",
|
||||
dest: currentVersionArchiveFolder + "/mithril.js",
|
||||
dest: currentVersionArchiveFolder + "/mithril.js"
|
||||
},
|
||||
|
||||
minified: {
|
||||
src: "mithril.min.js",
|
||||
dest: currentVersionArchiveFolder + "/mithril.min.js",
|
||||
dest: currentVersionArchiveFolder + "/mithril.min.js"
|
||||
},
|
||||
|
||||
readme: {
|
||||
src: "README.md",
|
||||
dest: currentVersionArchiveFolder + "/README.md",
|
||||
dest: currentVersionArchiveFolder + "/README.md"
|
||||
},
|
||||
|
||||
map: {
|
||||
src: "mithril.min.js.map",
|
||||
dest: currentVersionArchiveFolder + "/mithril.min.js.map",
|
||||
dest: currentVersionArchiveFolder + "/mithril.min.js.map"
|
||||
},
|
||||
|
||||
typescript: {
|
||||
src: "mithril.d.ts",
|
||||
dest: currentVersionArchiveFolder + "/mithril.d.ts",
|
||||
dest: currentVersionArchiveFolder + "/mithril.d.ts"
|
||||
},
|
||||
|
||||
publish: {
|
||||
expand: true,
|
||||
cwd: currentVersionArchiveFolder,
|
||||
src: "./**",
|
||||
dest: outputFolder,
|
||||
dest: outputFolder
|
||||
},
|
||||
|
||||
archive: {
|
||||
expand: true,
|
||||
cwd: currentVersionArchiveFolder,
|
||||
src: "./**",
|
||||
dest: outputFolder + "/archive/v" + pkg.version,
|
||||
},
|
||||
dest: outputFolder + "/archive/v" + pkg.version
|
||||
}
|
||||
},
|
||||
|
||||
"saucelabs-browsers": {
|
||||
|
|
@ -246,7 +246,7 @@ module.exports = function (grunt) { // eslint-disable-line
|
|||
return version === "dev" || version === "beta" ||
|
||||
+version >= 38 // The latest ESR version
|
||||
})
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
chrome: {
|
||||
|
|
@ -257,7 +257,7 @@ module.exports = function (grunt) { // eslint-disable-line
|
|||
return version === "dev" || version === "beta" ||
|
||||
+version >= 41
|
||||
})
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
ie: {
|
||||
|
|
@ -266,7 +266,7 @@ module.exports = function (grunt) { // eslint-disable-line
|
|||
return browser.browserName === "internet explorer" &&
|
||||
!/2003/.test(browser.platform)
|
||||
})
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
edge: {
|
||||
|
|
@ -274,7 +274,7 @@ module.exports = function (grunt) { // eslint-disable-line
|
|||
return browsers.filter(function (browser) {
|
||||
return browser.browserName === "microsoftedge"
|
||||
})
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
safari: {
|
||||
|
|
@ -282,7 +282,7 @@ module.exports = function (grunt) { // eslint-disable-line
|
|||
return browsers.filter(function (browser) {
|
||||
return browser.browserName === "safari"
|
||||
})
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
opera: {
|
||||
|
|
@ -290,8 +290,8 @@ module.exports = function (grunt) { // eslint-disable-line
|
|||
return browsers.filter(function (browser) {
|
||||
return browser.browserName === "opera"
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
saucelabs: {
|
||||
|
|
@ -304,7 +304,7 @@ module.exports = function (grunt) { // eslint-disable-line
|
|||
urls: ["http://localhost:8000/test/index.html"],
|
||||
sauceConfig: {
|
||||
"record-video": false,
|
||||
"record-screenshots": false,
|
||||
"record-screenshots": false
|
||||
},
|
||||
build: process.env.TRAVIS_JOB_ID,
|
||||
onTestComplete: function (result, callback) {
|
||||
|
|
@ -313,13 +313,13 @@ module.exports = function (grunt) { // eslint-disable-line
|
|||
|
||||
var url = [
|
||||
"https://saucelabs.com/rest/v1", user, "jobs",
|
||||
result.job_id,
|
||||
result.job_id
|
||||
].join("/")
|
||||
|
||||
require("request").put({
|
||||
url: url,
|
||||
auth: {user: user, pass: pass},
|
||||
json: {passed: result.passed},
|
||||
json: {passed: result.passed}
|
||||
}, function (error, response) {
|
||||
if (error) {
|
||||
return callback(error)
|
||||
|
|
@ -332,24 +332,24 @@ module.exports = function (grunt) { // eslint-disable-line
|
|||
}
|
||||
})
|
||||
},
|
||||
tunnelTimeout: 5,
|
||||
},
|
||||
},
|
||||
tunnelTimeout: 5
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
connect: {
|
||||
server: {
|
||||
options: {
|
||||
port: 8888,
|
||||
base: ".",
|
||||
},
|
||||
},
|
||||
base: "."
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
clean: {
|
||||
options: {force: true},
|
||||
generated: [tempFolder],
|
||||
},
|
||||
generated: [tempFolder]
|
||||
}
|
||||
})
|
||||
|
||||
grunt.loadNpmTasks("grunt-saucelabs-browsers")
|
||||
|
|
@ -371,7 +371,7 @@ module.exports = function (grunt) { // eslint-disable-line
|
|||
"md2html",
|
||||
"replace",
|
||||
"copy",
|
||||
"clean",
|
||||
"clean"
|
||||
])
|
||||
|
||||
grunt.registerTask("test", ["eslint:all", "mocha_phantomjs"])
|
||||
|
|
@ -380,6 +380,6 @@ module.exports = function (grunt) { // eslint-disable-line
|
|||
grunt.registerTask("sauce", [
|
||||
"saucelabs-browsers:all",
|
||||
"connect",
|
||||
"saucelabs",
|
||||
"saucelabs"
|
||||
])
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ window.templateConverter = (function () {
|
|||
return [
|
||||
new DOMParser()
|
||||
.parseFromString(markup, "text/html")
|
||||
.childNodes[1],
|
||||
.childNodes[1]
|
||||
]
|
||||
}
|
||||
|
||||
|
|
@ -39,7 +39,7 @@ window.templateConverter = (function () {
|
|||
list.push({
|
||||
tag: el.nodeName.toLowerCase(),
|
||||
attrs: attrs,
|
||||
children: createVirtual(el.childNodes),
|
||||
children: createVirtual(el.childNodes)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
|
@ -115,7 +115,7 @@ window.templateConverter = (function () {
|
|||
var body = this.virtuals.join("," + tab)
|
||||
return "[" + tab + body + tab.slice(0, -1) + "]"
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
@ -134,12 +134,12 @@ window.templateConverter = (function () {
|
|||
m("textarea", {
|
||||
autofocus: true,
|
||||
style: {width: "100%", height: "40%"},
|
||||
onchange: m.withAttr("value", ctrl.source),
|
||||
onchange: m.withAttr("value", ctrl.source)
|
||||
}, ctrl.source()),
|
||||
m("button", {onclick: ctrl.convert}, "Convert"),
|
||||
m("textarea", {style: {width: "100%", height: "40%"}},
|
||||
ctrl.output()),
|
||||
ctrl.output())
|
||||
])
|
||||
},
|
||||
}
|
||||
}
|
||||
})()
|
||||
|
|
|
|||
22
mithril.js
22
mithril.js
|
|
@ -231,7 +231,7 @@ void (function (global, factory) { // eslint-disable-line
|
|||
index: i,
|
||||
from: existing[key].index,
|
||||
element: cached.nodes[existing[key].index] ||
|
||||
$document.createElement("div"),
|
||||
$document.createElement("div")
|
||||
}
|
||||
} else {
|
||||
existing[key] = {action: INSERTION, index: i}
|
||||
|
|
@ -263,7 +263,7 @@ void (function (global, factory) { // eslint-disable-line
|
|||
insertNode(parent, dummy, index)
|
||||
newCached.splice(index, 0, {
|
||||
attrs: {key: data[index].attrs.key},
|
||||
nodes: [dummy],
|
||||
nodes: [dummy]
|
||||
})
|
||||
newCached.nodes[index] = dummy
|
||||
break
|
||||
|
|
@ -694,7 +694,7 @@ void (function (global, factory) { // eslint-disable-line
|
|||
tag: data.tag,
|
||||
attrs: attrs,
|
||||
children: children,
|
||||
nodes: [node],
|
||||
nodes: [node]
|
||||
}
|
||||
|
||||
unloadCachedControllers(cached, views, controllers)
|
||||
|
|
@ -732,7 +732,7 @@ void (function (global, factory) { // eslint-disable-line
|
|||
if (controller.onunload != null) {
|
||||
unloaders.push({
|
||||
controller: controller,
|
||||
handler: controller.onunload,
|
||||
handler: controller.onunload
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -1133,7 +1133,7 @@ void (function (global, factory) { // eslint-disable-line
|
|||
this.appendChild(node)
|
||||
},
|
||||
|
||||
childNodes: [],
|
||||
childNodes: []
|
||||
}
|
||||
|
||||
var nodeCache = []
|
||||
|
|
@ -1296,7 +1296,7 @@ void (function (global, factory) { // eslint-disable-line
|
|||
preventDefault: function () {
|
||||
isPrevented = true
|
||||
computePreRedrawHook = computePostRedrawHook = null
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
forEach(unloaders, function (unloader) {
|
||||
|
|
@ -1434,7 +1434,7 @@ void (function (global, factory) { // eslint-disable-line
|
|||
var modes = {
|
||||
pathname: "",
|
||||
hash: "#",
|
||||
search: "?",
|
||||
search: "?"
|
||||
}
|
||||
|
||||
var redirect = noop
|
||||
|
|
@ -1955,8 +1955,8 @@ void (function (global, factory) { // eslint-disable-line
|
|||
options.onload({
|
||||
type: "load",
|
||||
target: {
|
||||
responseText: resp,
|
||||
},
|
||||
responseText: resp
|
||||
}
|
||||
})
|
||||
|
||||
window[callbackKey] = undefined
|
||||
|
|
@ -1969,8 +1969,8 @@ void (function (global, factory) { // eslint-disable-line
|
|||
type: "error",
|
||||
target: {
|
||||
status: 500,
|
||||
responseText: '{"error": "Error making jsonp request"}',
|
||||
},
|
||||
responseText: '{"error": "Error making jsonp request"}'
|
||||
}
|
||||
})
|
||||
|
||||
window[callbackKey] = undefined
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ this.mock = (function (global) {
|
|||
// the browser. Still waiting on mocha-phantomjs to update to be
|
||||
// compatible with PhantomJS 2.x.
|
||||
phantom: global.window && global.window.navigator &&
|
||||
/PhantomJS/.test(global.window.navigator.userAgent),
|
||||
/PhantomJS/.test(global.window.navigator.userAgent)
|
||||
}
|
||||
|
||||
var document = window.document = {
|
||||
|
|
@ -102,7 +102,7 @@ this.mock = (function (global) {
|
|||
},
|
||||
|
||||
addEventListener: function () {},
|
||||
removeEventListener: function () {},
|
||||
removeEventListener: function () {}
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -156,7 +156,7 @@ this.mock = (function (global) {
|
|||
|
||||
traverse(document)
|
||||
return out
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
document.documentElement = document.createElement("html")
|
||||
|
|
@ -182,7 +182,7 @@ this.mock = (function (global) {
|
|||
indices[id] = callbacks.length
|
||||
callbacks.push({
|
||||
callback: callback,
|
||||
id: id,
|
||||
id: id
|
||||
})
|
||||
return id
|
||||
}
|
||||
|
|
@ -258,7 +258,7 @@ this.mock = (function (global) {
|
|||
|
||||
replaceState: function (data, title, url) {
|
||||
location.pathname = location.search = location.hash = url
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
return window
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ runner.on('fail', function (test, err) {
|
|||
result: false,
|
||||
message: err.message,
|
||||
stack: err.stack,
|
||||
titles: flattenTitles(test),
|
||||
titles: flattenTitles(test)
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
function test(sel) {
|
||||
return m("li", [
|
||||
m("p", m("code", "m(" + JSON.stringify(sel) + ")")),
|
||||
m.apply(null, arguments),
|
||||
m.apply(null, arguments)
|
||||
])
|
||||
}
|
||||
|
||||
|
|
@ -35,18 +35,18 @@ m.module(document.getElementById("test"), {
|
|||
m("ul", [
|
||||
test("input[list=data]", {
|
||||
onkeyup: m.withAttr("value", ctrl.title),
|
||||
value: ctrl.title(),
|
||||
value: ctrl.title()
|
||||
}),
|
||||
|
||||
test("datalist#data", [
|
||||
m("option", "John"),
|
||||
m("option", "Bob"),
|
||||
m("option", "Mary"),
|
||||
m("option", "Mary")
|
||||
]),
|
||||
|
||||
test("textarea", {
|
||||
onkeyup: m.withAttr("value", ctrl.title),
|
||||
value: ctrl.title(),
|
||||
value: ctrl.title()
|
||||
}),
|
||||
|
||||
m("li", [
|
||||
|
|
@ -55,7 +55,7 @@ m.module(document.getElementById("test"), {
|
|||
m("div[contenteditable]", {
|
||||
style: {border: "1px solid #888"},
|
||||
onkeyup: m.withAttr("innerHTML", ctrl.title)
|
||||
}, ctrl.title()),
|
||||
}, ctrl.title())
|
||||
]),
|
||||
|
||||
m("li", [
|
||||
|
|
@ -63,11 +63,11 @@ m.module(document.getElementById("test"), {
|
|||
m("code", "m(\"div[contenteditable]\")")),
|
||||
m("div[contenteditable]", {
|
||||
style: {border: "1px solid #888"},
|
||||
onkeyup: m.withAttr("innerHTML", ctrl.title),
|
||||
}, m.trust(ctrl.title())),
|
||||
]),
|
||||
]),
|
||||
onkeyup: m.withAttr("innerHTML", ctrl.title)
|
||||
}, m.trust(ctrl.title()))
|
||||
])
|
||||
])
|
||||
])
|
||||
},
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -202,7 +202,7 @@ describe("m()", function () {
|
|||
controller: spy,
|
||||
view: function () {
|
||||
return m("div", "testing")
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
var args = {age: 12}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ describe("m.mount()", function () {
|
|||
function pure(view) {
|
||||
return {
|
||||
controller: function () {},
|
||||
view: view,
|
||||
view: view
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -38,7 +38,7 @@ describe("m.mount()", function () {
|
|||
return [
|
||||
whatever % 2 ? m("span", "% 2") : undefined,
|
||||
m("div", "bugs"),
|
||||
m("a"),
|
||||
m("a")
|
||||
]
|
||||
})
|
||||
|
||||
|
|
@ -64,7 +64,7 @@ describe("m.mount()", function () {
|
|||
|
||||
var mod1 = m.mount(root1, {
|
||||
controller: controller1,
|
||||
view: view1,
|
||||
view: view1
|
||||
})
|
||||
|
||||
var controller2 = sinon.spy(function () { this.value = "test2" }) // eslint-disable-line
|
||||
|
|
@ -73,7 +73,7 @@ describe("m.mount()", function () {
|
|||
|
||||
var mod2 = mount(root2, {
|
||||
controller: controller2,
|
||||
view: view2,
|
||||
view: view2
|
||||
})
|
||||
|
||||
expect(controller1).to.have.been.called
|
||||
|
|
@ -97,7 +97,7 @@ describe("m.mount()", function () {
|
|||
controller: function () {
|
||||
this.onunload = spy
|
||||
},
|
||||
view: function () {},
|
||||
view: function () {}
|
||||
})
|
||||
|
||||
clear(root)
|
||||
|
|
@ -114,7 +114,7 @@ describe("m.mount()", function () {
|
|||
|
||||
var component = {
|
||||
controller: ctrlSpy,
|
||||
view: viewSpy,
|
||||
view: viewSpy
|
||||
}
|
||||
|
||||
var arg = {}
|
||||
|
|
@ -148,7 +148,7 @@ describe("m.mount()", function () {
|
|||
|
||||
var sub = {
|
||||
controller: ctrlSpy,
|
||||
view: viewSpy,
|
||||
view: viewSpy
|
||||
}
|
||||
|
||||
mount(root, pure(function () { return sub }))
|
||||
|
|
@ -168,7 +168,7 @@ describe("m.mount()", function () {
|
|||
|
||||
var subsub = {
|
||||
controller: ctrl1,
|
||||
view: view1,
|
||||
view: view1
|
||||
}
|
||||
|
||||
var ctrl2 = sinon.spy()
|
||||
|
|
@ -176,7 +176,7 @@ describe("m.mount()", function () {
|
|||
|
||||
var sub = {
|
||||
controller: ctrl2,
|
||||
view: view2,
|
||||
view: view2
|
||||
}
|
||||
|
||||
mount(root, pure(function () { return sub }))
|
||||
|
|
@ -326,7 +326,7 @@ describe("m.mount()", function () {
|
|||
},
|
||||
view: function () {
|
||||
return m("div")
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
mount(root, pure(function () {
|
||||
|
|
@ -358,7 +358,7 @@ describe("m.mount()", function () {
|
|||
},
|
||||
view: function () {
|
||||
return m("div")
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
var sub = {
|
||||
|
|
@ -367,7 +367,7 @@ describe("m.mount()", function () {
|
|||
},
|
||||
view: function (ctrl, opts) {
|
||||
return m.component(subsub, {key: opts.key})
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
mount(root, pure(function () {
|
||||
|
|
@ -400,7 +400,7 @@ describe("m.mount()", function () {
|
|||
controller: function () {
|
||||
m.redraw()
|
||||
},
|
||||
view: spy,
|
||||
view: spy
|
||||
}
|
||||
|
||||
mount(root, pure(function () { return sub }))
|
||||
|
|
@ -418,7 +418,7 @@ describe("m.mount()", function () {
|
|||
controller: function () {
|
||||
m.redraw()
|
||||
},
|
||||
view: spy,
|
||||
view: spy
|
||||
}
|
||||
|
||||
var sub = pure(function () { return subsub })
|
||||
|
|
@ -439,14 +439,14 @@ describe("m.mount()", function () {
|
|||
var CommentList = pure(function (ctrl, props) {
|
||||
return m(".list", props.list.map(function (i) {
|
||||
return m(".comment", [
|
||||
m.component(Reply, {key: i}),
|
||||
m.component(Reply, {key: i})
|
||||
])
|
||||
}))
|
||||
})
|
||||
|
||||
mount(root, pure(function () {
|
||||
return m(".outer", [
|
||||
m(".inner", m.component(CommentList, {list: [1, 2, 3]})),
|
||||
m(".inner", m.component(CommentList, {list: [1, 2, 3]}))
|
||||
])
|
||||
}))
|
||||
|
||||
|
|
@ -461,7 +461,7 @@ describe("m.mount()", function () {
|
|||
controller: function () {
|
||||
this.onunload = spy
|
||||
},
|
||||
view: function () {},
|
||||
view: function () {}
|
||||
})
|
||||
|
||||
m.mount(root, pure(function () {}))
|
||||
|
|
@ -479,7 +479,7 @@ describe("m.mount()", function () {
|
|||
return m("div", {
|
||||
config: function (el, init) {
|
||||
if (init) count += 1
|
||||
},
|
||||
}
|
||||
})
|
||||
}))
|
||||
|
||||
|
|
@ -505,9 +505,9 @@ describe("m.mount()", function () {
|
|||
m(".foo", {
|
||||
key: 1,
|
||||
config: test,
|
||||
onclick: function () { show = !show },
|
||||
onclick: function () { show = !show }
|
||||
}),
|
||||
show ? m(".bar", {key: 2}) : null,
|
||||
show ? m(".bar", {key: 2}) : null
|
||||
]
|
||||
}))
|
||||
|
||||
|
|
@ -529,9 +529,9 @@ describe("m.mount()", function () {
|
|||
mount(root, pure(function () {
|
||||
return show ? [
|
||||
m("h1", "1"),
|
||||
sub,
|
||||
sub
|
||||
] : [
|
||||
m("h1", "2"),
|
||||
m("h1", "2")
|
||||
]
|
||||
}))
|
||||
|
||||
|
|
@ -560,10 +560,10 @@ describe("m.mount()", function () {
|
|||
a = !a
|
||||
m.redraw(true)
|
||||
found = root.childNodes[0].childNodes[1]
|
||||
},
|
||||
}
|
||||
}, "asd"),
|
||||
a ? m("#a", "aaa") : null,
|
||||
"test",
|
||||
"test"
|
||||
])
|
||||
})
|
||||
|
||||
|
|
@ -572,7 +572,7 @@ describe("m.mount()", function () {
|
|||
|
||||
config: function (el, init, ctx) {
|
||||
if (!init) ctx.onunload = onunload
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
m.mount(root, pure(function () { return Comp }))
|
||||
|
|
@ -602,10 +602,10 @@ describe("m.mount()", function () {
|
|||
m.redraw(true)
|
||||
found = root.childNodes[0].childNodes[1]
|
||||
m.redraw.strategy("none")
|
||||
},
|
||||
}
|
||||
}, "asd"),
|
||||
a ? m("#a", "aaa") : null,
|
||||
"test",
|
||||
"test"
|
||||
])
|
||||
})
|
||||
|
||||
|
|
@ -614,7 +614,7 @@ describe("m.mount()", function () {
|
|||
|
||||
config: function (el, init, ctx) {
|
||||
if (!init) ctx.onunload = onunload
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
m.mount(root, pure(function () { return Comp }))
|
||||
|
|
@ -634,7 +634,7 @@ describe("m.mount()", function () {
|
|||
|
||||
var root = mock.document.createElement("div")
|
||||
var view = sinon.stub().returns(m("div", {
|
||||
onclick: function () { m.redraw(true) },
|
||||
onclick: function () { m.redraw(true) }
|
||||
}))
|
||||
|
||||
m.mount(root, pure(view))
|
||||
|
|
@ -666,7 +666,7 @@ describe("m.mount()", function () {
|
|||
this.foo = m.request({method: "GET", url: "/foo"})
|
||||
},
|
||||
|
||||
view: view,
|
||||
view: view
|
||||
}
|
||||
|
||||
mount(root, pure(function () { return Comp }))
|
||||
|
|
@ -691,20 +691,20 @@ describe("m.mount()", function () {
|
|||
controller: function () {
|
||||
this.foo = m.request({method: "GET", url: "/foo"})
|
||||
},
|
||||
view: view1,
|
||||
view: view1
|
||||
}
|
||||
|
||||
var Comp2 = {
|
||||
controller: function () {
|
||||
this.bar = m.request({method: "GET", url: "/bar"})
|
||||
},
|
||||
view: view2,
|
||||
view: view2
|
||||
}
|
||||
|
||||
mount(root, pure(function () {
|
||||
return m("div", [
|
||||
Comp1,
|
||||
Comp2,
|
||||
Comp2
|
||||
])
|
||||
}))
|
||||
|
||||
|
|
@ -751,7 +751,7 @@ describe("m.mount()", function () {
|
|||
return m("div", {
|
||||
config: function (el, init, ctx) {
|
||||
ctx.onunload = onunload
|
||||
},
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
|
|
@ -794,9 +794,9 @@ describe("m.mount()", function () {
|
|||
ctrl.bar = true
|
||||
m.redraw(true)
|
||||
el = root.childNodes[0].childNodes[1]
|
||||
},
|
||||
}
|
||||
}, "click me"),
|
||||
ctrl.bar ? m.component(sub) : "",
|
||||
ctrl.bar ? m.component(sub) : ""
|
||||
])
|
||||
}))
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ describe("m.redraw()", function () {
|
|||
|
||||
m.mount(root, {
|
||||
controller: function () { ctx = this }, // eslint-disable-line
|
||||
view: function (ctrl) { return ctrl.value },
|
||||
view: function (ctrl) { return ctrl.value }
|
||||
})
|
||||
|
||||
mock.requestAnimationFrame.$resolve()
|
||||
|
|
@ -38,7 +38,7 @@ describe("m.redraw()", function () {
|
|||
|
||||
m.mount(root, {
|
||||
controller: function () {},
|
||||
view: view,
|
||||
view: view
|
||||
})
|
||||
mock.requestAnimationFrame.$resolve() // teardown
|
||||
m.redraw()
|
||||
|
|
@ -57,7 +57,7 @@ describe("m.redraw()", function () {
|
|||
var view = sinon.spy()
|
||||
m.mount(root, {
|
||||
controller: function () {},
|
||||
view: view,
|
||||
view: view
|
||||
})
|
||||
mock.requestAnimationFrame.$resolve() // teardown
|
||||
m.redraw(true)
|
||||
|
|
@ -88,7 +88,7 @@ describe("m.redraw()", function () {
|
|||
function pure(view) {
|
||||
return {
|
||||
controller: noop,
|
||||
view: view,
|
||||
view: view
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -138,8 +138,8 @@ describe("m.redraw()", function () {
|
|||
},
|
||||
view: function () {
|
||||
return m("div")
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
expect(strategy).to.equal("all")
|
||||
|
|
@ -164,8 +164,8 @@ describe("m.redraw()", function () {
|
|||
},
|
||||
view: function () {
|
||||
return m("div", {config: config})
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
route("/bar1")
|
||||
|
|
@ -185,10 +185,10 @@ describe("m.redraw()", function () {
|
|||
strategy = m.redraw.strategy()
|
||||
ctrl.number++
|
||||
m.redraw.strategy("none")
|
||||
},
|
||||
}
|
||||
}, ctrl.number)
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
})
|
||||
root.childNodes[0].onclick({})
|
||||
mock.requestAnimationFrame.$resolve()
|
||||
|
|
@ -211,9 +211,9 @@ describe("m.redraw()", function () {
|
|||
config: config,
|
||||
onclick: function () {
|
||||
m.redraw.strategy("all")
|
||||
},
|
||||
}
|
||||
})
|
||||
}),
|
||||
})
|
||||
})
|
||||
root.childNodes[0].onclick({})
|
||||
mock.requestAnimationFrame.$resolve()
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ describe("m.render()", function () {
|
|||
m.render(root, m("svg", [m("g")]))
|
||||
expect(root.childNodes[0].childNodes[0]).to.contain.all.keys({
|
||||
nodeName: "G",
|
||||
namespaceURI: "http://www.w3.org/2000/svg",
|
||||
namespaceURI: "http://www.w3.org/2000/svg"
|
||||
})
|
||||
})
|
||||
|
||||
|
|
@ -237,7 +237,7 @@ describe("m.render()", function () {
|
|||
m.render(root, m("#foo", [
|
||||
[m("div", "a"), m("div", "b")],
|
||||
[m("div", "c"), m("div", "d")],
|
||||
m("#bar"),
|
||||
m("#bar")
|
||||
]))
|
||||
|
||||
expect(root.childNodes[0].childNodes[3].childNodes[0].nodeValue)
|
||||
|
|
@ -269,7 +269,7 @@ describe("m.render()", function () {
|
|||
["a", "b", "c", "d"].map(function () {
|
||||
return [m("div"), " "]
|
||||
}),
|
||||
m("span"),
|
||||
m("span")
|
||||
]))
|
||||
expect(root.childNodes[0].childNodes[8].nodeName).to.equal("SPAN")
|
||||
})
|
||||
|
|
@ -282,7 +282,7 @@ describe("m.render()", function () {
|
|||
|
||||
m.render(root, m("#foo", [
|
||||
[m("div", "a"), m("div", "b"), m("div", "c")],
|
||||
m("#bar"),
|
||||
m("#bar")
|
||||
]))
|
||||
|
||||
expect(root.childNodes[0].childNodes[2].childNodes[0].nodeValue)
|
||||
|
|
@ -295,12 +295,12 @@ describe("m.render()", function () {
|
|||
|
||||
m.render(root, m("main", [
|
||||
m("button"),
|
||||
m("article", [m("section"), m("nav")]),
|
||||
m("article", [m("section"), m("nav")])
|
||||
]))
|
||||
|
||||
m.render(root, m("main", [
|
||||
m("button"),
|
||||
m("article", [m("span"), m("nav")]),
|
||||
m("article", [m("span"), m("nav")])
|
||||
]))
|
||||
|
||||
expect(root.childNodes[0].childNodes[1].childNodes[0].nodeName)
|
||||
|
|
@ -313,12 +313,12 @@ describe("m.render()", function () {
|
|||
|
||||
m.render(root, m("main", [
|
||||
m("button"),
|
||||
m("article", [m("section"), m("nav")]),
|
||||
m("article", [m("section"), m("nav")])
|
||||
]))
|
||||
|
||||
m.render(root, m("main", [
|
||||
m("button"),
|
||||
m("article", ["test", m("nav")]),
|
||||
m("article", ["test", m("nav")])
|
||||
]))
|
||||
|
||||
expect(root.childNodes[0].childNodes[1].childNodes[0].nodeValue)
|
||||
|
|
@ -331,12 +331,12 @@ describe("m.render()", function () {
|
|||
|
||||
m.render(root, m("main", [
|
||||
m("button"),
|
||||
m("article", [m("section"), m("nav")]),
|
||||
m("article", [m("section"), m("nav")])
|
||||
]))
|
||||
|
||||
m.render(root, m("main", [
|
||||
m("button"),
|
||||
m("article", [m.trust("test"), m("nav")]),
|
||||
m("article", [m.trust("test"), m("nav")])
|
||||
]))
|
||||
|
||||
expect(root.childNodes[0].childNodes[1].childNodes[0].nodeValue)
|
||||
|
|
@ -550,7 +550,7 @@ describe("m.render()", function () {
|
|||
var config = sinon.spy()
|
||||
|
||||
m.render(root, m("div", {
|
||||
config: function (el, init, ctx) { ctx.data = 1 },
|
||||
config: function (el, init, ctx) { ctx.data = 1 }
|
||||
}))
|
||||
|
||||
m.render(root, m("div", {config: config}))
|
||||
|
|
@ -564,7 +564,7 @@ describe("m.render()", function () {
|
|||
var index = 0
|
||||
|
||||
var node = m("div", {
|
||||
config: function (el, init, ctx) { ctx.data = index++ },
|
||||
config: function (el, init, ctx) { ctx.data = index++ }
|
||||
})
|
||||
|
||||
m.render(root, [node, node])
|
||||
|
|
@ -604,7 +604,7 @@ describe("m.render()", function () {
|
|||
m.render(root, m("div", [
|
||||
["foo", "bar"],
|
||||
["foo", "bar"],
|
||||
["foo", "bar"],
|
||||
["foo", "bar"]
|
||||
]))
|
||||
|
||||
m.render(root, m("div", ["asdf", "asdf2", "asdf3"]))
|
||||
|
|
@ -619,7 +619,7 @@ describe("m.render()", function () {
|
|||
m.render(root, [
|
||||
m("a", {key: 1}, 1),
|
||||
m("a", {key: 2}, 2),
|
||||
m("a", {key: 3}, 3),
|
||||
m("a", {key: 3}, 3)
|
||||
])
|
||||
|
||||
var firstBefore = root.childNodes[0]
|
||||
|
|
@ -628,7 +628,7 @@ describe("m.render()", function () {
|
|||
m("a", {key: 4}, 4),
|
||||
m("a", {key: 1}, 1),
|
||||
m("a", {key: 2}, 2),
|
||||
m("a", {key: 3}, 3),
|
||||
m("a", {key: 3}, 3)
|
||||
])
|
||||
|
||||
var firstAfter = root.childNodes[1]
|
||||
|
|
@ -648,7 +648,7 @@ describe("m.render()", function () {
|
|||
m.render(root, [
|
||||
m("a", {key: 1}, 1),
|
||||
m("a", {key: 2}, 2),
|
||||
m("a", {key: 3}, 3),
|
||||
m("a", {key: 3}, 3)
|
||||
])
|
||||
|
||||
var firstBefore = root.childNodes[0]
|
||||
|
|
@ -656,7 +656,7 @@ describe("m.render()", function () {
|
|||
m.render(root, [
|
||||
m("a", {key: 4}, 4),
|
||||
m("a", {key: 1}, 1),
|
||||
m("a", {key: 2}, 2),
|
||||
m("a", {key: 2}, 2)
|
||||
])
|
||||
|
||||
var firstAfter = root.childNodes[1]
|
||||
|
|
@ -676,7 +676,7 @@ describe("m.render()", function () {
|
|||
m.render(root, [
|
||||
m("a", {key: 1}, 1),
|
||||
m("a", {key: 2}, 2),
|
||||
m("a", {key: 3}, 3),
|
||||
m("a", {key: 3}, 3)
|
||||
])
|
||||
|
||||
var firstBefore = root.childNodes[1]
|
||||
|
|
@ -684,7 +684,7 @@ describe("m.render()", function () {
|
|||
m.render(root, [
|
||||
m("a", {key: 2}, 2),
|
||||
m("a", {key: 3}, 3),
|
||||
m("a", {key: 4}, 4),
|
||||
m("a", {key: 4}, 4)
|
||||
])
|
||||
|
||||
var firstAfter = root.childNodes[0]
|
||||
|
|
@ -706,7 +706,7 @@ describe("m.render()", function () {
|
|||
m("a", {key: 2}, 2),
|
||||
m("a", {key: 3}, 3),
|
||||
m("a", {key: 4}, 4),
|
||||
m("a", {key: 5}, 5),
|
||||
m("a", {key: 5}, 5)
|
||||
])
|
||||
|
||||
var firstBefore = root.childNodes[0]
|
||||
|
|
@ -717,7 +717,7 @@ describe("m.render()", function () {
|
|||
m("a", {key: 4}, 4),
|
||||
m("a", {key: 10}, 10),
|
||||
m("a", {key: 1}, 1),
|
||||
m("a", {key: 2}, 2),
|
||||
m("a", {key: 2}, 2)
|
||||
])
|
||||
|
||||
var firstAfter = root.childNodes[2]
|
||||
|
|
@ -740,7 +740,7 @@ describe("m.render()", function () {
|
|||
m("a", {key: 2}, 2),
|
||||
m("a", {key: 3}, 3),
|
||||
m("a", {key: 4}, 4),
|
||||
m("a", {key: 5}, 5),
|
||||
m("a", {key: 5}, 5)
|
||||
])
|
||||
|
||||
var firstBefore = root.childNodes[0]
|
||||
|
|
@ -753,7 +753,7 @@ describe("m.render()", function () {
|
|||
m("a", {key: 2}, 2),
|
||||
m("a", {key: 1}, 1),
|
||||
m("a", {key: 6}, 6),
|
||||
m("a", {key: 7}, 7),
|
||||
m("a", {key: 7}, 7)
|
||||
])
|
||||
|
||||
var firstAfter = root.childNodes[3]
|
||||
|
|
@ -780,7 +780,7 @@ describe("m.render()", function () {
|
|||
m("a", {key: 2}),
|
||||
m("a"),
|
||||
m("a", {key: 4}),
|
||||
m("a", {key: 5}),
|
||||
m("a", {key: 5})
|
||||
])
|
||||
|
||||
var firstBefore = root.childNodes[0]
|
||||
|
|
@ -794,7 +794,7 @@ describe("m.render()", function () {
|
|||
m("a", {key: 5}),
|
||||
m("a"),
|
||||
m("a", {key: 1}),
|
||||
m("a", {key: 2}),
|
||||
m("a", {key: 2})
|
||||
])
|
||||
|
||||
var firstAfter = root.childNodes[3]
|
||||
|
|
@ -848,8 +848,8 @@ describe("m.render()", function () {
|
|||
key: 1,
|
||||
config: function (el, init, ctx) {
|
||||
ctx.onunload = spy
|
||||
},
|
||||
}),
|
||||
}
|
||||
})
|
||||
])
|
||||
m.render(root, [
|
||||
m("div", {key: 2}),
|
||||
|
|
@ -857,8 +857,8 @@ describe("m.render()", function () {
|
|||
key: 1,
|
||||
config: function (el, init, ctx) {
|
||||
ctx.onunload = spy
|
||||
},
|
||||
}),
|
||||
}
|
||||
})
|
||||
])
|
||||
expect(spy).to.not.have.been.called
|
||||
})
|
||||
|
|
@ -917,7 +917,7 @@ describe("m.render()", function () {
|
|||
m.render(root, m("ul", [
|
||||
m("li", {key: 0}, 0),
|
||||
m("li", {key: 2}, 2),
|
||||
m("li", {key: 4}, 4),
|
||||
m("li", {key: 4}, 4)
|
||||
]))
|
||||
|
||||
m.render(root, m("ul", [
|
||||
|
|
@ -926,7 +926,7 @@ describe("m.render()", function () {
|
|||
m("li", {key: 2}, 2),
|
||||
m("li", {key: 3}, 3),
|
||||
m("li", {key: 4}, 4),
|
||||
m("li", {key: 5}, 5),
|
||||
m("li", {key: 5}, 5)
|
||||
]))
|
||||
|
||||
expect(
|
||||
|
|
@ -962,7 +962,7 @@ describe("m.render()", function () {
|
|||
m("li", {key: 2}, 2),
|
||||
m("li", {key: 3}, 3),
|
||||
m("li", {key: 4}, 4),
|
||||
m("li", {key: 5}, 5),
|
||||
m("li", {key: 5}, 5)
|
||||
]))
|
||||
|
||||
m.render(root, m("ul", [
|
||||
|
|
@ -970,7 +970,7 @@ describe("m.render()", function () {
|
|||
m("li", {key: 1}, 1),
|
||||
m("li", {key: 2}, 2),
|
||||
m("li", {key: 4}, 4),
|
||||
m("li", {key: 5}, 5),
|
||||
m("li", {key: 5}, 5)
|
||||
]))
|
||||
|
||||
expect(
|
||||
|
|
@ -990,7 +990,7 @@ describe("m.render()", function () {
|
|||
m("li", {key: 2}, 2),
|
||||
m("li", {key: 3}, 3),
|
||||
m("li", {key: 4}, 4),
|
||||
m("li", {key: 5}, 5),
|
||||
m("li", {key: 5}, 5)
|
||||
]))
|
||||
|
||||
m.render(root, m("ul", [
|
||||
|
|
@ -999,7 +999,7 @@ describe("m.render()", function () {
|
|||
m("li", {key: 3}, 3),
|
||||
m("li", {key: 4}, 4),
|
||||
m("li", {key: 5}, 5),
|
||||
m("li", {key: 6}, 6),
|
||||
m("li", {key: 6}, 6)
|
||||
]))
|
||||
|
||||
m.render(root, m("ul", [
|
||||
|
|
@ -1008,7 +1008,7 @@ describe("m.render()", function () {
|
|||
m("li", {key: 14}, 14),
|
||||
m("li", {key: 15}, 15),
|
||||
m("li", {key: 16}, 16),
|
||||
m("li", {key: 17}, 17),
|
||||
m("li", {key: 17}, 17)
|
||||
]))
|
||||
|
||||
expect(
|
||||
|
|
@ -1044,7 +1044,7 @@ describe("m.render()", function () {
|
|||
m.render(root, [m("div", {
|
||||
config: function (el, init, ctx) {
|
||||
ctx.onunload = onunload1
|
||||
},
|
||||
}
|
||||
})])
|
||||
|
||||
m.render(root, [])
|
||||
|
|
@ -1052,7 +1052,7 @@ describe("m.render()", function () {
|
|||
m.render(root, [m("div", {
|
||||
config: function (el, init, ctx) {
|
||||
ctx.onunload = onunload2
|
||||
},
|
||||
}
|
||||
})])
|
||||
|
||||
m.render(root, [])
|
||||
|
|
@ -1068,7 +1068,7 @@ describe("m.render()", function () {
|
|||
|
||||
m.render(root, [
|
||||
m("div.green", [m("div")]),
|
||||
m("div.blue"),
|
||||
m("div.blue")
|
||||
])
|
||||
|
||||
expect(root.childNodes).to.have.length(2)
|
||||
|
|
@ -1102,7 +1102,7 @@ describe("m.render()", function () {
|
|||
m("div", {key: 3}, 3),
|
||||
m("div", {key: 4}, 4),
|
||||
m("div", {key: 5}, 5),
|
||||
null, null, null, null, null, null, null, null, null, null,
|
||||
null, null, null, null, null, null, null, null, null, null
|
||||
]))
|
||||
|
||||
m.render(root, m("div", [
|
||||
|
|
@ -1115,7 +1115,7 @@ describe("m.render()", function () {
|
|||
null, null,
|
||||
m("div", {key: 12}, 12),
|
||||
null, null,
|
||||
m("div", {key: 15}, 15),
|
||||
m("div", {key: 15}, 15)
|
||||
]))
|
||||
|
||||
m.render(root, m("div", [
|
||||
|
|
@ -1124,7 +1124,7 @@ describe("m.render()", function () {
|
|||
m("div", {key: 3}, 3),
|
||||
m("div", {key: 4}, 4),
|
||||
m("div", {key: 5}, 5),
|
||||
null, null, null, null, null, null, null, null, null, null,
|
||||
null, null, null, null, null, null, null, null, null, null
|
||||
]))
|
||||
|
||||
expect(
|
||||
|
|
@ -1145,9 +1145,9 @@ describe("m.render()", function () {
|
|||
[
|
||||
m("div", {key: 3}, 3),
|
||||
m("div", {key: 4}, 4),
|
||||
m("div", {key: 5}, 5),
|
||||
m("div", {key: 5}, 5)
|
||||
],
|
||||
[m("div", {key: 6}, 6)],
|
||||
[m("div", {key: 6}, 6)]
|
||||
]))
|
||||
|
||||
m.render(root, m("div", [
|
||||
|
|
@ -1156,9 +1156,9 @@ describe("m.render()", function () {
|
|||
[
|
||||
m("div", {key: 3}, 3),
|
||||
m("div", {key: 4}, 4),
|
||||
m("div", {key: 5}, 5),
|
||||
m("div", {key: 5}, 5)
|
||||
],
|
||||
[m("div", {key: 6}, 6)],
|
||||
[m("div", {key: 6}, 6)]
|
||||
]))
|
||||
|
||||
expect(
|
||||
|
|
@ -1183,7 +1183,7 @@ describe("m.render()", function () {
|
|||
m.render(root, [
|
||||
m("#div-1", {key: 1}),
|
||||
m("#div-2", {key: 2}),
|
||||
m("#div-3", {key: 3}),
|
||||
m("#div-3", {key: 3})
|
||||
])
|
||||
|
||||
root.appendChild(root.childNodes[1])
|
||||
|
|
@ -1191,7 +1191,7 @@ describe("m.render()", function () {
|
|||
m.render(root, [
|
||||
m("#div-1", {key: 1}),
|
||||
m("#div-3", {key: 3}),
|
||||
m("#div-2", {key: 2}),
|
||||
m("#div-2", {key: 2})
|
||||
])
|
||||
|
||||
expect(
|
||||
|
|
@ -1228,7 +1228,7 @@ describe("m.render()", function () {
|
|||
m("a", {key: 1}),
|
||||
m("a", {key: 2}),
|
||||
m("a", {key: 3}),
|
||||
m("i"),
|
||||
m("i")
|
||||
]))
|
||||
var before = root.childNodes[0].childNodes[3]
|
||||
|
||||
|
|
@ -1236,7 +1236,7 @@ describe("m.render()", function () {
|
|||
m("b", {key: 3}),
|
||||
m("b", {key: 4}),
|
||||
m("i"),
|
||||
m("b", {key: 1}),
|
||||
m("b", {key: 1})
|
||||
]))
|
||||
var after = root.childNodes[0].childNodes[2]
|
||||
|
||||
|
|
@ -1251,7 +1251,7 @@ describe("m.render()", function () {
|
|||
m("a", {key: 2}),
|
||||
"foo",
|
||||
m("a", {key: 3}),
|
||||
m("i"),
|
||||
m("i")
|
||||
]))
|
||||
var before = root.childNodes[0].childNodes[4]
|
||||
|
||||
|
|
@ -1260,7 +1260,7 @@ describe("m.render()", function () {
|
|||
m("a", {key: 4}),
|
||||
"bar",
|
||||
m("i"),
|
||||
m("a", {key: 1}),
|
||||
m("a", {key: 1})
|
||||
]))
|
||||
var after = root.childNodes[0].childNodes[3]
|
||||
|
||||
|
|
@ -1275,7 +1275,7 @@ describe("m.render()", function () {
|
|||
m("a", {key: 2}),
|
||||
null,
|
||||
m("a", {key: 3}),
|
||||
m("i"),
|
||||
m("i")
|
||||
]))
|
||||
var before = root.childNodes[0].childNodes[4]
|
||||
|
||||
|
|
@ -1284,7 +1284,7 @@ describe("m.render()", function () {
|
|||
m("a", {key: 4}),
|
||||
null,
|
||||
m("i"),
|
||||
m("a", {key: 1}),
|
||||
m("a", {key: 1})
|
||||
]))
|
||||
var after = root.childNodes[0].childNodes[3]
|
||||
|
||||
|
|
@ -1299,7 +1299,7 @@ describe("m.render()", function () {
|
|||
m("a", {key: 2}),
|
||||
undefined,
|
||||
m("a", {key: 3}),
|
||||
m("i"),
|
||||
m("i")
|
||||
]))
|
||||
var before = root.childNodes[0].childNodes[4]
|
||||
|
||||
|
|
@ -1308,7 +1308,7 @@ describe("m.render()", function () {
|
|||
m("a", {key: 4}),
|
||||
undefined,
|
||||
m("i"),
|
||||
m("a", {key: 1}),
|
||||
m("a", {key: 1})
|
||||
]))
|
||||
var after = root.childNodes[0].childNodes[3]
|
||||
|
||||
|
|
@ -1325,7 +1325,7 @@ describe("m.render()", function () {
|
|||
m("a", {key: 2}),
|
||||
m.trust("a"),
|
||||
m("a", {key: 3}),
|
||||
m("i"),
|
||||
m("i")
|
||||
]))
|
||||
var before = root.childNodes[0].childNodes[4]
|
||||
|
||||
|
|
@ -1334,7 +1334,7 @@ describe("m.render()", function () {
|
|||
m("a", {key: 4}),
|
||||
m.trust("a"),
|
||||
m("i"),
|
||||
m("a", {key: 1}),
|
||||
m("a", {key: 1})
|
||||
]))
|
||||
var after = root.childNodes[0].childNodes[3]
|
||||
|
||||
|
|
@ -1360,7 +1360,7 @@ describe("m.render()", function () {
|
|||
m.render(root, m("div", {}, [
|
||||
m("div", {}, "0"),
|
||||
m("div", {}, "1"),
|
||||
m("div", {}, "2"),
|
||||
m("div", {}, "2")
|
||||
]))
|
||||
|
||||
expect(
|
||||
|
|
@ -1370,7 +1370,7 @@ describe("m.render()", function () {
|
|||
).to.eql(["0", "1", "2"])
|
||||
|
||||
m.render(root, m("div", {}, [
|
||||
m("div", {}, "0"),
|
||||
m("div", {}, "0")
|
||||
]))
|
||||
|
||||
expect(
|
||||
|
|
@ -1385,7 +1385,7 @@ describe("m.render()", function () {
|
|||
m.render(root, m("span", {}, [
|
||||
m("div", {}, "0"),
|
||||
m("div", {}, "1"),
|
||||
m("div", {}, "2"),
|
||||
m("div", {}, "2")
|
||||
]))
|
||||
|
||||
expect(
|
||||
|
|
@ -1395,7 +1395,7 @@ describe("m.render()", function () {
|
|||
).to.eql(["0", "1", "2"])
|
||||
|
||||
m.render(root, m("span", {}, [
|
||||
m("div", {}, "0"),
|
||||
m("div", {}, "0")
|
||||
]))
|
||||
|
||||
expect(
|
||||
|
|
@ -1420,9 +1420,9 @@ describe("m.render()", function () {
|
|||
view: function (ctrl) {
|
||||
return m("input", {
|
||||
value: ctrl.inputValue(),
|
||||
onkeyup: m.withAttr("value", ctrl.inputValue),
|
||||
onkeyup: m.withAttr("value", ctrl.inputValue)
|
||||
})
|
||||
},
|
||||
}
|
||||
})
|
||||
mock.requestAnimationFrame.$resolve()
|
||||
|
||||
|
|
@ -1466,11 +1466,11 @@ describe("m.render()", function () {
|
|||
return m("form", {onsubmit: ctrl.submit}, [
|
||||
m("input", {
|
||||
onkeyup: m.withAttr("value", ctrl.inputValue),
|
||||
value: ctrl.inputValue(),
|
||||
value: ctrl.inputValue()
|
||||
}),
|
||||
m("button[type=submit]"),
|
||||
m("button[type=submit]")
|
||||
])
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
var form = root.childNodes[0]
|
||||
|
|
@ -1511,7 +1511,7 @@ describe("m.render()", function () {
|
|||
view: function (ctrl) {
|
||||
return m("select", {
|
||||
size: ctrl.values.length,
|
||||
multiple: "multiple",
|
||||
multiple: "multiple"
|
||||
}, [
|
||||
ctrl.values.map(function (v) {
|
||||
var opts = {value: v}
|
||||
|
|
@ -1519,9 +1519,9 @@ describe("m.render()", function () {
|
|||
opts.selected = "selected"
|
||||
}
|
||||
return m("option", opts, v)
|
||||
}),
|
||||
})
|
||||
])
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
mock.requestAnimationFrame.$resolve()
|
||||
|
|
|
|||
|
|
@ -21,12 +21,12 @@ describe("m.request()", function () {
|
|||
it("sets the correct properties on `GET`", function () {
|
||||
var prop = request({
|
||||
method: "GET",
|
||||
url: "test",
|
||||
url: "test"
|
||||
})
|
||||
|
||||
expect(prop()).to.contain.keys({
|
||||
method: "GET",
|
||||
url: "test",
|
||||
url: "test"
|
||||
})
|
||||
})
|
||||
|
||||
|
|
@ -49,12 +49,12 @@ describe("m.request()", function () {
|
|||
var prop = request({
|
||||
method: "POST",
|
||||
url: "http://domain.com:80",
|
||||
data: {},
|
||||
data: {}
|
||||
})
|
||||
|
||||
expect(prop()).to.contain.keys({
|
||||
method: "POST",
|
||||
url: "http://domain.com:80",
|
||||
url: "http://domain.com:80"
|
||||
})
|
||||
})
|
||||
|
||||
|
|
@ -62,7 +62,7 @@ describe("m.request()", function () {
|
|||
expect(request({
|
||||
method: "POST",
|
||||
url: "http://domain.com:80/:test1",
|
||||
data: {test1: "foo"},
|
||||
data: {test1: "foo"}
|
||||
})().url).to.equal("http://domain.com:80/foo")
|
||||
})
|
||||
|
||||
|
|
@ -72,7 +72,7 @@ describe("m.request()", function () {
|
|||
var prop = m.request({
|
||||
method: "GET",
|
||||
url: "test",
|
||||
deserialize: function () { throw new Error("error occurred") },
|
||||
deserialize: function () { throw new Error("error occurred") }
|
||||
}).then(null, error)
|
||||
resolve()
|
||||
|
||||
|
|
@ -86,7 +86,7 @@ describe("m.request()", function () {
|
|||
var prop = m.request({
|
||||
method: "GET",
|
||||
url: "test",
|
||||
deserialize: function () { throw new Error("error occurred") },
|
||||
deserialize: function () { throw new Error("error occurred") }
|
||||
}).catch(error)
|
||||
resolve()
|
||||
|
||||
|
|
@ -99,7 +99,7 @@ describe("m.request()", function () {
|
|||
var data = m.prop()
|
||||
var prop = m.request({
|
||||
method: "GET",
|
||||
url: "test",
|
||||
url: "test"
|
||||
})
|
||||
.then(function () { return "foo" })
|
||||
.finally(data)
|
||||
|
|
@ -142,7 +142,7 @@ describe("m.request()", function () {
|
|||
var prop = m.request({
|
||||
method: "GET",
|
||||
url: "test",
|
||||
deserialize: function () { throw new Error("error occurred") },
|
||||
deserialize: function () { throw new Error("error occurred") }
|
||||
})
|
||||
.catch(error)
|
||||
.finally(function () { error("finally") })
|
||||
|
|
@ -158,7 +158,7 @@ describe("m.request()", function () {
|
|||
var prop = m.request({
|
||||
method: "GET",
|
||||
url: "test",
|
||||
deserialize: function () { throw new TypeError("error occurred") },
|
||||
deserialize: function () { throw new TypeError("error occurred") }
|
||||
}).then(null, error)
|
||||
|
||||
try {
|
||||
|
|
@ -178,7 +178,7 @@ describe("m.request()", function () {
|
|||
m.request({
|
||||
method: "POST",
|
||||
url: "test",
|
||||
data: {foo: 1},
|
||||
data: {foo: 1}
|
||||
}).then(null, error)
|
||||
|
||||
var xhr = mock.XMLHttpRequest.$instances.pop()
|
||||
|
|
@ -194,7 +194,7 @@ describe("m.request()", function () {
|
|||
|
||||
m.request({
|
||||
method: "POST",
|
||||
url: "test",
|
||||
url: "test"
|
||||
}).then(null, error)
|
||||
|
||||
var xhr = mock.XMLHttpRequest.$instances.pop()
|
||||
|
|
@ -207,7 +207,7 @@ describe("m.request()", function () {
|
|||
var prop = m.request({
|
||||
method: "POST",
|
||||
url: "test",
|
||||
initialValue: "foo",
|
||||
initialValue: "foo"
|
||||
})
|
||||
|
||||
var initialValue = prop()
|
||||
|
|
@ -220,7 +220,7 @@ describe("m.request()", function () {
|
|||
var prop = m.request({
|
||||
method: "POST",
|
||||
url: "test",
|
||||
initialValue: "foo",
|
||||
initialValue: "foo"
|
||||
}).then(function (value) { return value })
|
||||
|
||||
var initialValue = prop()
|
||||
|
|
@ -233,7 +233,7 @@ describe("m.request()", function () {
|
|||
var prop = m.request({
|
||||
method: "POST",
|
||||
url: "test",
|
||||
initialValue: "foo",
|
||||
initialValue: "foo"
|
||||
}).then(function () { return "bar" })
|
||||
|
||||
resolve()
|
||||
|
|
@ -290,7 +290,7 @@ describe("m.request()", function () {
|
|||
url: "/test",
|
||||
dataType: "jsonp",
|
||||
data: data,
|
||||
callbackKey: callbackKey,
|
||||
callbackKey: callbackKey
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,11 +15,11 @@ describe("m.route.buildQueryString()", function () {
|
|||
foo: "bar",
|
||||
hello: ["world", "mars", "mars"],
|
||||
world: {
|
||||
test: 3,
|
||||
test: 3
|
||||
},
|
||||
bam: "",
|
||||
yup: null,
|
||||
removed: undefined,
|
||||
removed: undefined
|
||||
})
|
||||
).to.equal("foo=bar&hello=world&hello=mars&world%5Btest%5D=3&bam=&yup")
|
||||
})
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ describe("m.route()", function () {
|
|||
var types = {
|
||||
search: "?",
|
||||
hash: "#",
|
||||
pathname: "/",
|
||||
pathname: "/"
|
||||
}
|
||||
|
||||
return function (type) {
|
||||
|
|
@ -32,7 +32,7 @@ describe("m.route()", function () {
|
|||
function pure(view) {
|
||||
return {
|
||||
controller: noop,
|
||||
view: view,
|
||||
view: view
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -74,7 +74,7 @@ describe("m.route()", function () {
|
|||
mode("search")
|
||||
|
||||
route(root, "/test1", {
|
||||
"/test1": pure(function () { return "foo" }),
|
||||
"/test1": pure(function () { return "foo" })
|
||||
})
|
||||
|
||||
expect(mock.location.search).to.equal("?/test1")
|
||||
|
|
@ -88,12 +88,12 @@ describe("m.route()", function () {
|
|||
route(root, "/", {
|
||||
"/": {
|
||||
controller: function () { route1 = m.route() },
|
||||
view: noop,
|
||||
view: noop
|
||||
},
|
||||
"/test13": {
|
||||
controller: function () { route2 = m.route() },
|
||||
view: noop,
|
||||
},
|
||||
view: noop
|
||||
}
|
||||
})
|
||||
|
||||
m.route("/test13")
|
||||
|
|
@ -113,7 +113,7 @@ describe("m.route()", function () {
|
|||
},
|
||||
view: function () {
|
||||
return m("div")
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
route(root, "/a", {
|
||||
|
|
@ -121,8 +121,8 @@ describe("m.route()", function () {
|
|||
|
||||
"/b": {
|
||||
controller: spy,
|
||||
view: noop,
|
||||
},
|
||||
view: noop
|
||||
}
|
||||
})
|
||||
|
||||
route("/b")
|
||||
|
|
@ -142,7 +142,7 @@ describe("m.route()", function () {
|
|||
},
|
||||
view: function () {
|
||||
return m("div")
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
var sub = pure(function () { return subsub })
|
||||
|
|
@ -152,8 +152,8 @@ describe("m.route()", function () {
|
|||
|
||||
"/b": {
|
||||
controller: spy,
|
||||
view: noop,
|
||||
},
|
||||
view: noop
|
||||
}
|
||||
})
|
||||
|
||||
route("/b")
|
||||
|
|
@ -173,7 +173,7 @@ describe("m.route()", function () {
|
|||
},
|
||||
view: function () {
|
||||
return m("div")
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
route(root, "/a", {
|
||||
|
|
@ -181,8 +181,8 @@ describe("m.route()", function () {
|
|||
|
||||
"/b": {
|
||||
controller: spy,
|
||||
view: noop,
|
||||
},
|
||||
view: noop
|
||||
}
|
||||
})
|
||||
|
||||
route("/b")
|
||||
|
|
@ -202,7 +202,7 @@ describe("m.route()", function () {
|
|||
},
|
||||
view: function () {
|
||||
return m("div")
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
var sub = pure(function () { return subsub })
|
||||
|
|
@ -212,8 +212,8 @@ describe("m.route()", function () {
|
|||
|
||||
"/b": {
|
||||
controller: spy,
|
||||
view: noop,
|
||||
},
|
||||
view: noop
|
||||
}
|
||||
})
|
||||
|
||||
route("/b")
|
||||
|
|
@ -229,26 +229,26 @@ describe("m.route()", function () {
|
|||
|
||||
var sub1 = {
|
||||
controller: ctrl1,
|
||||
view: function () { return m("div") },
|
||||
view: function () { return m("div") }
|
||||
}
|
||||
|
||||
var sub2 = {
|
||||
controller: ctrl2,
|
||||
view: function () { return m("div") },
|
||||
view: function () { return m("div") }
|
||||
}
|
||||
|
||||
route(root, "/a", {
|
||||
"/a": pure(function () {
|
||||
return m(".page-a", [
|
||||
m("h1"), m.component(sub1, {x: 11}),
|
||||
m("h1"), m.component(sub1, {x: 11})
|
||||
])
|
||||
}),
|
||||
|
||||
"/b": pure(function () {
|
||||
return m(".page-b", [
|
||||
m("h2"), m.component(sub2, {y: 22}),
|
||||
m("h2"), m.component(sub2, {y: 22})
|
||||
])
|
||||
}),
|
||||
})
|
||||
})
|
||||
|
||||
route("/b")
|
||||
|
|
@ -264,7 +264,7 @@ describe("m.route()", function () {
|
|||
var Component = pure(function () { return m(".comp") })
|
||||
|
||||
route(root, "/foo", {
|
||||
"/foo": pure(function () { return [Component] }),
|
||||
"/foo": pure(function () { return [Component] })
|
||||
})
|
||||
|
||||
expect(root.childNodes[0].nodeName).to.equal("DIV")
|
||||
|
|
@ -279,7 +279,7 @@ describe("m.route()", function () {
|
|||
|
||||
view: function (ctrl) {
|
||||
return m("div", ctrl.name)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
route(root, "/", {
|
||||
|
|
@ -287,7 +287,7 @@ describe("m.route()", function () {
|
|||
return m("div", [
|
||||
m("a[href=/]", {config: m.route}, "foo"),
|
||||
m("a[href=/bar]", {config: m.route}, "bar"),
|
||||
m.component(MyComponent, {name: "Jane"}),
|
||||
m.component(MyComponent, {name: "Jane"})
|
||||
])
|
||||
}),
|
||||
|
||||
|
|
@ -295,9 +295,9 @@ describe("m.route()", function () {
|
|||
return m("div", [
|
||||
m("a[href=/]", {config: m.route}, "foo"),
|
||||
m("a[href=/bar]", {config: m.route}, "bar"),
|
||||
m.component(MyComponent, {name: "Bob"}),
|
||||
m.component(MyComponent, {name: "Bob"})
|
||||
])
|
||||
}),
|
||||
})
|
||||
})
|
||||
|
||||
route("/bar")
|
||||
|
|
@ -313,9 +313,9 @@ describe("m.route()", function () {
|
|||
"/test2": pure(function () {
|
||||
return [
|
||||
"foo",
|
||||
m("a", {href: "/test2", config: m.route}, "Test2"),
|
||||
m("a", {href: "/test2", config: m.route}, "Test2")
|
||||
]
|
||||
}),
|
||||
})
|
||||
})
|
||||
|
||||
expect(mock.location.pathname).to.equal("/test2")
|
||||
|
|
@ -327,7 +327,7 @@ describe("m.route()", function () {
|
|||
mode("hash")
|
||||
|
||||
route(root, "/test3", {
|
||||
"/test3": pure(function () { return "foo" }),
|
||||
"/test3": pure(function () { return "foo" })
|
||||
})
|
||||
|
||||
expect(mock.location.hash).to.equal("#/test3")
|
||||
|
|
@ -338,7 +338,7 @@ describe("m.route()", function () {
|
|||
mode("search")
|
||||
|
||||
route(root, "/test4/foo", {
|
||||
"/test4/:test": pure(function () { return m.route.param("test") }),
|
||||
"/test4/:test": pure(function () { return m.route.param("test") })
|
||||
})
|
||||
|
||||
expect(mock.location.search).to.equal("?/test4/foo")
|
||||
|
|
@ -357,7 +357,7 @@ describe("m.route()", function () {
|
|||
|
||||
m.route(root, "/test5/foo", {
|
||||
"/": component,
|
||||
"/test5/:test": component,
|
||||
"/test5/:test": component
|
||||
})
|
||||
|
||||
var paramValueBefore = m.route.param("test")
|
||||
|
|
@ -381,7 +381,7 @@ describe("m.route()", function () {
|
|||
|
||||
m.route(root, "/test6/foo", {
|
||||
"/": component,
|
||||
"/test6/:a1": component,
|
||||
"/test6/:a1": component
|
||||
})
|
||||
|
||||
var paramValueBefore = m.route.param("a1")
|
||||
|
|
@ -406,7 +406,7 @@ describe("m.route()", function () {
|
|||
|
||||
m.route(root, "/test7/foo", {
|
||||
"/": component,
|
||||
"/test7/:a1": component,
|
||||
"/test7/:a1": component
|
||||
})
|
||||
|
||||
var routeValueBefore = m.route()
|
||||
|
|
@ -428,7 +428,7 @@ describe("m.route()", function () {
|
|||
route(root, "/test8/foo/SEP/bar/baz", {
|
||||
"/test8/:test/SEP/:path...": pure(function () {
|
||||
return m.route.param("test") + "_" + m.route.param("path")
|
||||
}),
|
||||
})
|
||||
})
|
||||
|
||||
expect(mock.location.search).to.equal("?/test8/foo/SEP/bar/baz")
|
||||
|
|
@ -441,7 +441,7 @@ describe("m.route()", function () {
|
|||
route(root, "/test9/foo/bar/SEP/baz", {
|
||||
"/test9/:test.../SEP/:path": pure(function () {
|
||||
return m.route.param("test") + "_" + m.route.param("path")
|
||||
}),
|
||||
})
|
||||
})
|
||||
|
||||
expect(mock.location.search).to.equal("?/test9/foo/bar/SEP/baz")
|
||||
|
|
@ -454,7 +454,7 @@ describe("m.route()", function () {
|
|||
route(root, "/test10/foo%20bar", {
|
||||
"/test10/:test": pure(function () {
|
||||
return m.route.param("test")
|
||||
}),
|
||||
})
|
||||
})
|
||||
|
||||
expect(root.childNodes[0].nodeValue).to.equal("foo bar")
|
||||
|
|
@ -465,7 +465,7 @@ describe("m.route()", function () {
|
|||
|
||||
route(root, "/", {
|
||||
"/": pure(function () { return "foo" }),
|
||||
"/test11": pure(function () { return "bar" }),
|
||||
"/test11": pure(function () { return "bar" })
|
||||
})
|
||||
|
||||
route("/test11/")
|
||||
|
|
@ -479,7 +479,7 @@ describe("m.route()", function () {
|
|||
|
||||
route(root, "/", {
|
||||
"/": pure(noop),
|
||||
"/test12": pure(noop),
|
||||
"/test12": pure(noop)
|
||||
})
|
||||
|
||||
route("/test12?a=foo&b=bar")
|
||||
|
|
@ -496,7 +496,7 @@ describe("m.route()", function () {
|
|||
"/": pure(function () { return "bar" }),
|
||||
"/test13/:test": pure(function () {
|
||||
return m.route.param("test")
|
||||
}),
|
||||
})
|
||||
})
|
||||
|
||||
route("/test13/foo?test=bar")
|
||||
|
|
@ -510,7 +510,7 @@ describe("m.route()", function () {
|
|||
|
||||
route(root, "/", {
|
||||
"/": pure(function () { return "bar" }),
|
||||
"/test14": pure(function () { return "foo" }),
|
||||
"/test14": pure(function () { return "foo" })
|
||||
})
|
||||
|
||||
route("/test14?test&test2=")
|
||||
|
|
@ -525,7 +525,7 @@ describe("m.route()", function () {
|
|||
|
||||
route(root, "/", {
|
||||
"/": pure(noop),
|
||||
"/test12": pure(noop),
|
||||
"/test12": pure(noop)
|
||||
})
|
||||
|
||||
route("/test12", {a: "foo", b: "bar"})
|
||||
|
|
@ -540,7 +540,7 @@ describe("m.route()", function () {
|
|||
|
||||
route(root, "/", {
|
||||
"/": pure(noop),
|
||||
"/test12": pure(noop),
|
||||
"/test12": pure(noop)
|
||||
})
|
||||
|
||||
route("/test12", {a: "foo", b: "bar"})
|
||||
|
|
@ -562,10 +562,10 @@ describe("m.route()", function () {
|
|||
return m("div", {
|
||||
config: function (el, init, ctx) {
|
||||
ctx.onunload = onunload
|
||||
},
|
||||
}
|
||||
})
|
||||
}),
|
||||
"/test14": pure(noop),
|
||||
"/test14": pure(noop)
|
||||
})
|
||||
|
||||
route("/test14")
|
||||
|
|
@ -585,11 +585,11 @@ describe("m.route()", function () {
|
|||
m("div", {
|
||||
config: function (el, init, ctx) {
|
||||
ctx.onunload = onunload
|
||||
},
|
||||
}),
|
||||
}
|
||||
})
|
||||
]
|
||||
}),
|
||||
"/test15": pure(function () { return [m("div")] }),
|
||||
"/test15": pure(function () { return [m("div")] })
|
||||
})
|
||||
|
||||
route("/test15")
|
||||
|
|
@ -607,10 +607,10 @@ describe("m.route()", function () {
|
|||
return m("div", {
|
||||
config: function (el, init, ctx) {
|
||||
ctx.onunload = onunload
|
||||
},
|
||||
}
|
||||
})
|
||||
}),
|
||||
"/test16": pure(function () { return m("a") }),
|
||||
"/test16": pure(function () { return m("a") })
|
||||
})
|
||||
|
||||
route("/test16")
|
||||
|
|
@ -629,11 +629,11 @@ describe("m.route()", function () {
|
|||
m("div", {
|
||||
config: function (el, init, ctx) {
|
||||
ctx.onunload = onunload
|
||||
},
|
||||
}),
|
||||
}
|
||||
})
|
||||
]
|
||||
}),
|
||||
"/test17": pure(function () { return m("a") }),
|
||||
"/test17": pure(function () { return m("a") })
|
||||
})
|
||||
|
||||
route("/test17")
|
||||
|
|
@ -651,10 +651,10 @@ describe("m.route()", function () {
|
|||
return m("div", {
|
||||
config: function (el, init, ctx) {
|
||||
ctx.onunload = onunload
|
||||
},
|
||||
}
|
||||
})
|
||||
}),
|
||||
"/test18": pure(function () { return [m("a")] }),
|
||||
"/test18": pure(function () { return [m("a")] })
|
||||
})
|
||||
|
||||
route("/test18")
|
||||
|
|
@ -674,8 +674,8 @@ describe("m.route()", function () {
|
|||
key: 1,
|
||||
config: function (el, init, ctx) {
|
||||
ctx.onunload = onunload
|
||||
},
|
||||
}),
|
||||
}
|
||||
})
|
||||
]
|
||||
}),
|
||||
"/test20": pure(function () {
|
||||
|
|
@ -684,10 +684,10 @@ describe("m.route()", function () {
|
|||
key: 2,
|
||||
config: function (el, init, ctx) {
|
||||
ctx.onunload = onunload
|
||||
},
|
||||
}),
|
||||
}
|
||||
})
|
||||
]
|
||||
}),
|
||||
})
|
||||
})
|
||||
|
||||
route("/test20")
|
||||
|
|
@ -707,8 +707,8 @@ describe("m.route()", function () {
|
|||
key: 1,
|
||||
config: function (el, init, ctx) {
|
||||
ctx.onunload = onunload
|
||||
},
|
||||
}),
|
||||
}
|
||||
})
|
||||
]
|
||||
}),
|
||||
"/test21": pure(function () {
|
||||
|
|
@ -716,10 +716,10 @@ describe("m.route()", function () {
|
|||
m("div", {
|
||||
config: function (el, init, ctx) {
|
||||
ctx.onunload = onunload
|
||||
},
|
||||
}),
|
||||
}
|
||||
})
|
||||
]
|
||||
}),
|
||||
})
|
||||
})
|
||||
|
||||
route("/test21")
|
||||
|
|
@ -732,7 +732,7 @@ describe("m.route()", function () {
|
|||
|
||||
route(root, "/foo", {
|
||||
"/foo": pure(function () { return m("div", "foo") }),
|
||||
"/bar": pure(function () { return m("div", "bar") }),
|
||||
"/bar": pure(function () { return m("div", "bar") })
|
||||
})
|
||||
var foo = root.childNodes[0].childNodes[0].nodeValue
|
||||
|
||||
|
|
@ -757,7 +757,7 @@ describe("m.route()", function () {
|
|||
}),
|
||||
"/bar1": pure(function () {
|
||||
return m("main", m("a", {config: config}, "foo"))
|
||||
}),
|
||||
})
|
||||
})
|
||||
|
||||
route("/bar1")
|
||||
|
|
@ -774,8 +774,8 @@ describe("m.route()", function () {
|
|||
controller: function () { value = m.route.param("arg") },
|
||||
view: function () {
|
||||
return ""
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
})
|
||||
expect(value).to.equal("foo+bar")
|
||||
})
|
||||
|
|
@ -785,7 +785,7 @@ describe("m.route()", function () {
|
|||
|
||||
route(root, "/", {
|
||||
"/": pure(function () { return "foo" }),
|
||||
"/test22": pure(function () { return "bar" }),
|
||||
"/test22": pure(function () { return "bar" })
|
||||
})
|
||||
|
||||
m.route("/test22/")
|
||||
|
|
@ -799,7 +799,7 @@ describe("m.route()", function () {
|
|||
|
||||
route(root, "/", {
|
||||
"/": pure(function () { return "foo" }),
|
||||
"/test23": pure(function () { return "bar" }),
|
||||
"/test23": pure(function () { return "bar" })
|
||||
})
|
||||
|
||||
route(new String("/test23/")) // eslint-disable-line no-new-wrappers
|
||||
|
|
@ -817,8 +817,8 @@ describe("m.route()", function () {
|
|||
controller: function () { value = m.route.param("arg") },
|
||||
view: function () {
|
||||
return ""
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
})
|
||||
expect(value).to.equal("foo+bar")
|
||||
})
|
||||
|
|
@ -832,8 +832,8 @@ describe("m.route()", function () {
|
|||
controller: function () { value = m.route.param("arg") },
|
||||
view: function () {
|
||||
return ""
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
expect(value).to.equal("foo+bar")
|
||||
|
|
@ -845,10 +845,10 @@ describe("m.route()", function () {
|
|||
route(root, "/a", {
|
||||
"/a": {
|
||||
controller: function () { m.route("/b") },
|
||||
view: function () { return "a" },
|
||||
view: function () { return "a" }
|
||||
},
|
||||
|
||||
"/b": pure(function () { return "b" }),
|
||||
"/b": pure(function () { return "b" })
|
||||
})
|
||||
|
||||
expect(root.childNodes[0].nodeValue).to.equal("b")
|
||||
|
|
@ -862,9 +862,9 @@ describe("m.route()", function () {
|
|||
controller: function () {
|
||||
m.route("/b?foo=1", {foo: 2})
|
||||
},
|
||||
view: function () { return "a" },
|
||||
view: function () { return "a" }
|
||||
},
|
||||
"/b": pure(function () { return "b" }),
|
||||
"/b": pure(function () { return "b" })
|
||||
})
|
||||
|
||||
expect(mock.location.search).to.equal("?/b?foo=2")
|
||||
|
|
@ -876,7 +876,7 @@ describe("m.route()", function () {
|
|||
|
||||
route(root, "/a", {
|
||||
"/a": pure(function () { return "a" }),
|
||||
"/b": pure(function () { return "b" }),
|
||||
"/b": pure(function () { return "b" })
|
||||
})
|
||||
|
||||
route("/b")
|
||||
|
|
@ -890,7 +890,7 @@ describe("m.route()", function () {
|
|||
|
||||
route(root, "/a", {
|
||||
"/a": pure(function () { return "a" }),
|
||||
"/b": pure(function () { return "b" }),
|
||||
"/b": pure(function () { return "b" })
|
||||
})
|
||||
|
||||
route("/a")
|
||||
|
|
@ -908,13 +908,13 @@ describe("m.route()", function () {
|
|||
return m("a", {
|
||||
config: function (el, init) {
|
||||
if (!init) initCount++
|
||||
},
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
route(root, "/a", {
|
||||
"/a": a,
|
||||
"/b": pure(a.view),
|
||||
"/b": pure(a.view)
|
||||
})
|
||||
|
||||
route("/b")
|
||||
|
|
@ -931,13 +931,13 @@ describe("m.route()", function () {
|
|||
config: function (el, init, ctx) {
|
||||
ctx.retain = false
|
||||
if (!init) initCount++
|
||||
},
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
route(root, "/a", {
|
||||
"/a": a,
|
||||
"/b": pure(a.view),
|
||||
"/b": pure(a.view)
|
||||
})
|
||||
|
||||
route("/b")
|
||||
|
|
@ -954,13 +954,13 @@ describe("m.route()", function () {
|
|||
config: function (el, init, ctx) {
|
||||
ctx.retain = true
|
||||
if (!init) initCount++
|
||||
},
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
route(root, "/a", {
|
||||
"/a": a,
|
||||
"/b": pure(a.view),
|
||||
"/b": pure(a.view)
|
||||
})
|
||||
|
||||
route("/b")
|
||||
|
|
@ -984,7 +984,7 @@ describe("m.route()", function () {
|
|||
}),
|
||||
"/b": pure(function () {
|
||||
return m("section", m("a", {config: config}))
|
||||
}),
|
||||
})
|
||||
})
|
||||
|
||||
route("/b")
|
||||
|
|
@ -1006,7 +1006,7 @@ describe("m.route()", function () {
|
|||
}),
|
||||
"/b": pure(function () {
|
||||
return m("section", m("a", {config: config}))
|
||||
}),
|
||||
})
|
||||
})
|
||||
|
||||
route("/b")
|
||||
|
|
@ -1028,7 +1028,7 @@ describe("m.route()", function () {
|
|||
}),
|
||||
"/b": pure(function () {
|
||||
return m("section", m("a", {config: config}))
|
||||
}),
|
||||
})
|
||||
})
|
||||
|
||||
route("/b")
|
||||
|
|
@ -1042,7 +1042,7 @@ describe("m.route()", function () {
|
|||
function diff(view) {
|
||||
return {
|
||||
controller: function () { m.redraw.strategy("diff") },
|
||||
view: view,
|
||||
view: view
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1055,13 +1055,13 @@ describe("m.route()", function () {
|
|||
return m("a", {
|
||||
config: function (el, init) {
|
||||
if (!init) initCount++
|
||||
},
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
route(root, "/a", {
|
||||
"/a": a,
|
||||
"/b": diff(a.view),
|
||||
"/b": diff(a.view)
|
||||
})
|
||||
|
||||
route("/b")
|
||||
|
|
@ -1078,13 +1078,13 @@ describe("m.route()", function () {
|
|||
config: function (el, init, ctx) {
|
||||
ctx.retain = true
|
||||
if (!init) initCount++
|
||||
},
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
route(root, "/a", {
|
||||
"/a": a,
|
||||
"/b": diff(a.view),
|
||||
"/b": diff(a.view)
|
||||
})
|
||||
|
||||
route("/b")
|
||||
|
|
@ -1101,13 +1101,13 @@ describe("m.route()", function () {
|
|||
config: function (el, init, ctx) {
|
||||
ctx.retain = false
|
||||
if (!init) initCount++
|
||||
},
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
route(root, "/a", {
|
||||
"/a": a,
|
||||
"/b": diff(a.view),
|
||||
"/b": diff(a.view)
|
||||
})
|
||||
|
||||
route("/b")
|
||||
|
|
@ -1131,7 +1131,7 @@ describe("m.route()", function () {
|
|||
}),
|
||||
"/b": diff(function () {
|
||||
return m("section", m("a", {config: config}))
|
||||
}),
|
||||
})
|
||||
})
|
||||
|
||||
route("/b")
|
||||
|
|
@ -1154,7 +1154,7 @@ describe("m.route()", function () {
|
|||
}),
|
||||
"/b": diff(function () {
|
||||
return m("section", m("a", {config: config}))
|
||||
}),
|
||||
})
|
||||
})
|
||||
|
||||
route("/b")
|
||||
|
|
@ -1177,7 +1177,7 @@ describe("m.route()", function () {
|
|||
}),
|
||||
"/b": diff(function () {
|
||||
return m("section", m("a", {config: config}))
|
||||
}),
|
||||
})
|
||||
})
|
||||
|
||||
m.route("/b")
|
||||
|
|
@ -1204,12 +1204,12 @@ describe("m.route()", function () {
|
|||
controller: function () { m.redraw.strategy("diff") },
|
||||
view: function () {
|
||||
return m("section", m("a", {config: config}))
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
route(root, "/a", {
|
||||
"/a": pure(function () { return m("div", a) }),
|
||||
"/b": pure(function () { return m("div", b) }),
|
||||
"/b": pure(function () { return m("div", b) })
|
||||
})
|
||||
|
||||
route("/b")
|
||||
|
|
@ -1226,10 +1226,10 @@ describe("m.route()", function () {
|
|||
return m("div", {
|
||||
config: function (el) {
|
||||
el.childNodes[0].modified = true
|
||||
},
|
||||
}
|
||||
}, m("div"))
|
||||
}),
|
||||
"/b": pure(function () { return m("div", m("div")) }),
|
||||
"/b": pure(function () { return m("div", m("div")) })
|
||||
})
|
||||
|
||||
route("/b")
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ describe("m.route.parseQueryString()", function () {
|
|||
foo: "bar",
|
||||
hello: ["world", "mars"],
|
||||
bam: "",
|
||||
yup: null,
|
||||
yup: null
|
||||
})
|
||||
})
|
||||
|
||||
|
|
@ -28,7 +28,7 @@ describe("m.route.parseQueryString()", function () {
|
|||
|
||||
expect(args).to.eql({
|
||||
foo: "bar",
|
||||
"hello[]": ["world", "mars", "pluto"],
|
||||
"hello[]": ["world", "mars", "pluto"]
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ describe("m.startComputation(), m.endComputation()", function () {
|
|||
var root = mock.document.createElement("div")
|
||||
var controller = m.mount(root, {
|
||||
controller: function () {},
|
||||
view: function (ctrl) { return ctrl.value },
|
||||
view: function (ctrl) { return ctrl.value }
|
||||
})
|
||||
|
||||
mock.requestAnimationFrame.$resolve()
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ describe("m.trust()", function () {
|
|||
var root = document.createElement("div")
|
||||
m.render(root, [
|
||||
m.trust("<p>1</p>123<p>2</p>"),
|
||||
m("i", "foo"),
|
||||
m("i", "foo")
|
||||
])
|
||||
expect(root.childNodes[3].tagName).to.equal("I")
|
||||
})
|
||||
|
|
@ -49,7 +49,7 @@ describe("m.trust()", function () {
|
|||
|
||||
m.render(root, [
|
||||
m.trust("<td>1</td><td>2</td>"),
|
||||
m("td", "foo"),
|
||||
m("td", "foo")
|
||||
])
|
||||
|
||||
expect(root.childNodes[2].tagName).to.equal("td")
|
||||
|
|
|
|||
|
|
@ -57,20 +57,20 @@ m.render(document.getElementById("test"), [
|
|||
height: 100,
|
||||
width: 100,
|
||||
transform: "translate(30) rotate(45 50 50)",
|
||||
style: {stroke: "#000", fill: "#0086b2"},
|
||||
style: {stroke: "#000", fill: "#0086b2"}
|
||||
}),
|
||||
m("a[href='http://google.com'][title='SVG link'][target=_new]", {
|
||||
style: {textDecoration: "underline"},
|
||||
style: {textDecoration: "underline"}
|
||||
}, [
|
||||
m("text[x=0][y=20]", "SVG Link"),
|
||||
]),
|
||||
m("text[x=0][y=20]", "SVG Link")
|
||||
])
|
||||
]),
|
||||
m("svg[height=201px][width=201px]", [
|
||||
m("image[href='http://placekitten.com/201/201']", {
|
||||
height: "200px",
|
||||
width: "200px",
|
||||
title: "Cat picture",
|
||||
}),
|
||||
title: "Cat picture"
|
||||
})
|
||||
]),
|
||||
m("svg[title='Line drawings']", {
|
||||
"enable-background": "new 0 0 340 333",
|
||||
|
|
@ -78,7 +78,7 @@ m.render(document.getElementById("test"), [
|
|||
viewBox: "0 0 340 333",
|
||||
width: "340px",
|
||||
x: "0px",
|
||||
y: "0px",
|
||||
y: "0px"
|
||||
}, [
|
||||
m("path.path", {
|
||||
d: [
|
||||
|
|
@ -94,13 +94,13 @@ m.render(document.getElementById("test"), [
|
|||
"s 11 -61 -11 -80",
|
||||
"s -79 -7 -70 -41",
|
||||
"C 46.039,146.545,53.039,128.545,66.039,133.545",
|
||||
"z",
|
||||
"z"
|
||||
].join(" "),
|
||||
fill: "#FFFFFF",
|
||||
stroke: "#000000",
|
||||
"stroke-miterlimit": 10,
|
||||
"stroke-width": 4,
|
||||
}),
|
||||
"stroke-width": 4
|
||||
})
|
||||
]),
|
||||
m("svg[height=270px][width=270px][viewBox='0 0 270 270']", [
|
||||
m("g[transform='translate(150,150)'][title=Clock]", [
|
||||
|
|
@ -109,7 +109,7 @@ m.render(document.getElementById("test"), [
|
|||
r: 108,
|
||||
fill: "none",
|
||||
"stroke-width": 4,
|
||||
stroke: "gray",
|
||||
stroke: "gray"
|
||||
}),
|
||||
m("circle", {
|
||||
r: 97,
|
||||
|
|
@ -117,7 +117,7 @@ m.render(document.getElementById("test"), [
|
|||
"stroke-width": 11,
|
||||
stroke: "black",
|
||||
"stroke-dasharray": "4,46.789082",
|
||||
transform: "rotate(-1.5)",
|
||||
transform: "rotate(-1.5)"
|
||||
}),
|
||||
m("circle", {
|
||||
r: 100,
|
||||
|
|
@ -125,8 +125,8 @@ m.render(document.getElementById("test"), [
|
|||
"stroke-width": 5,
|
||||
stroke: "black",
|
||||
"stroke-dasharray": "2,8.471976",
|
||||
transform: "rotate(-.873)",
|
||||
}),
|
||||
transform: "rotate(-.873)"
|
||||
})
|
||||
]),
|
||||
m("g[transform='rotate(180)']", [
|
||||
m("g#hour", [
|
||||
|
|
@ -135,15 +135,15 @@ m.render(document.getElementById("test"), [
|
|||
y2: 75,
|
||||
"stroke-linecap": "round",
|
||||
stroke: "blue",
|
||||
opacity: 0.5,
|
||||
opacity: 0.5
|
||||
}),
|
||||
m("animateTransform[attributeName=transform]", {
|
||||
type: "rotate",
|
||||
repeatCount: "indefinite",
|
||||
dur: "12h",
|
||||
by: 360,
|
||||
by: 360
|
||||
}),
|
||||
m("circle[r=7]"),
|
||||
m("circle[r=7]")
|
||||
]),
|
||||
m("g#minute", [
|
||||
m("line", {
|
||||
|
|
@ -151,15 +151,15 @@ m.render(document.getElementById("test"), [
|
|||
y2: 93,
|
||||
"stroke-linecap": "round",
|
||||
stroke: "green",
|
||||
opacity: 0.9,
|
||||
opacity: 0.9
|
||||
}),
|
||||
m("animateTransform[attributeName=transform]", {
|
||||
type: "rotate",
|
||||
repeatCount: "indefinite",
|
||||
dur: "60min",
|
||||
by: 360,
|
||||
by: 360
|
||||
}),
|
||||
m("circle[r=6][fill=red]"),
|
||||
m("circle[r=6][fill=red]")
|
||||
]),
|
||||
m("g#second", [
|
||||
m("line", {
|
||||
|
|
@ -167,17 +167,17 @@ m.render(document.getElementById("test"), [
|
|||
y1: -20,
|
||||
y2: 102,
|
||||
"stroke-linecap": "round",
|
||||
stroke: "red",
|
||||
stroke: "red"
|
||||
}),
|
||||
m("animateTransform[attributeName=transform]", {
|
||||
type: "rotate",
|
||||
repeatCount: "indefinite",
|
||||
dur: "60s",
|
||||
by: 360,
|
||||
by: 360
|
||||
}),
|
||||
m("circle[r=4][fill=blue]"),
|
||||
]),
|
||||
]),
|
||||
m("circle[r=4][fill=blue]")
|
||||
])
|
||||
])
|
||||
]),
|
||||
m("script", "(" + function () {
|
||||
"use strict"
|
||||
|
|
@ -195,7 +195,7 @@ m.render(document.getElementById("test"), [
|
|||
rotate("hour", 30 * (hours + minutes / 60 + seconds / 3600))
|
||||
rotate("minute", 6 * (minutes + seconds / 60))
|
||||
rotate("second", 6 * seconds)
|
||||
}.toString() + ")()"),
|
||||
}.toString() + ")()")
|
||||
]),
|
||||
m("svg[height=200px][width=200px]", [
|
||||
m("foreignObject", {
|
||||
|
|
@ -203,12 +203,12 @@ m.render(document.getElementById("test"), [
|
|||
y: 0,
|
||||
width: "100px",
|
||||
height: "100px",
|
||||
transform: "translate(0,0)",
|
||||
transform: "translate(0,0)"
|
||||
}, m("div", {xmlns: "http://www.w3.org/1999/xhtml"}, [
|
||||
m.trust("this is a piece of html rendered as " +
|
||||
"<a href=\"http://www.w3.org/TR/SVG11/extend.html\">" +
|
||||
"SVG foreignObject</a>"),
|
||||
])),
|
||||
]),
|
||||
"SVG foreignObject</a>")
|
||||
]))
|
||||
])
|
||||
])
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue