Merge pull request #729 from impinball/speed

Profile and optimize
This commit is contained in:
Leo Horie 2015-07-23 21:28:42 -04:00
commit b0c876f57b
7 changed files with 1178 additions and 1036 deletions

View file

@ -1,6 +1,5 @@
module.exports = function(grunt) { module.exports = function(grunt) {
_ = require('lodash'); var _ = require("lodash");
var version = "0.2.0"; var version = "0.2.0";
var inputFolder = "./docs"; var inputFolder = "./docs";
@ -8,7 +7,6 @@ module.exports = function(grunt) {
var archiveFolder = "./archive"; var archiveFolder = "./archive";
var outputFolder = "../mithril"; var outputFolder = "../mithril";
var guideLayout = "guide";
var guide = [ var guide = [
"auto-redrawing", "auto-redrawing",
"benchmarks", "benchmarks",
@ -25,7 +23,6 @@ module.exports = function(grunt) {
"tools", "tools",
"web-services" "web-services"
]; ];
var apiLayout = "api";
var api = [ var api = [
"change-log", "change-log",
"roadmap", "roadmap",
@ -47,8 +44,6 @@ module.exports = function(grunt) {
"mithril.xhr" "mithril.xhr"
]; ];
var md2htmlTasks = {}; var md2htmlTasks = {};
var makeTasks = function(layout, pages) { var makeTasks = function(layout, pages) {
pages.map(function(name) { pages.map(function(name) {
@ -83,7 +78,7 @@ module.exports = function(grunt) {
url: ['https://saucelabs.com/rest/v1', user, 'jobs', result.job_id].join('/'), url: ['https://saucelabs.com/rest/v1', user, 'jobs', result.job_id].join('/'),
auth: { user: user, pass: pass }, auth: { user: user, pass: pass },
json: { passed: result.passed } json: { passed: result.passed }
}, function (error, response, body) { }, function (error, response) {
if (error) { if (error) {
callback(error); callback(error);
} else if (response.statusCode !== 200) { } else if (response.statusCode !== 200) {

File diff suppressed because it is too large Load diff

2
mithril.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,6 @@
//saucelabs reporting; see https://github.com/axemclion/grunt-saucelabs#test-result-details-with-qunit //saucelabs reporting; see https://github.com/axemclion/grunt-saucelabs#test-result-details-with-qunit
var log = [] var log = []
var testName
QUnit.done(function (test_results) { QUnit.done(function (test_results) {
var tests = [] var tests = []
@ -85,7 +85,7 @@ test('array item removal', function() {
m('div', {}, '2') m('div', {}, '2')
]) ])
var view2= m('div', {}, [ var view2 = m('div', {}, [
m('div', {}, '0') m('div', {}, '0')
]) ])
@ -105,7 +105,7 @@ test('issue99 regression', function() {
m('div', {}, '2') m('div', {}, '2')
]) ])
var view2= m('div', {}, [ var view2 = m('div', {}, [
m('span', {}, '0') m('span', {}, '0')
]) ])
@ -124,7 +124,7 @@ test('config handler context', function() {
}}) }})
m.render(dummyEl, view) m.render(dummyEl, view)
var view = m('div', {config: function(evt, isInitialized, context) { view = m('div', {config: function(evt, isInitialized, context) {
equal(context instanceof Object, true) equal(context instanceof Object, true)
equal(context.data, 1) equal(context.data, 1)
}}) }})

File diff suppressed because it is too large Load diff

View file

@ -55,11 +55,11 @@ mock.window = (function() {
else this.childNodes.splice(referenceIndex, 0, node) else this.childNodes.splice(referenceIndex, 0, node)
}, },
insertAdjacentHTML: function(position, html) { insertAdjacentHTML: function(position, html) {
//todo: accept markup // todo: accept markup
if (position == "beforebegin") { if (position === "beforebegin") {
this.parentNode.insertBefore(window.document.createTextNode(html), this) this.parentNode.insertBefore(window.document.createTextNode(html), this)
} }
else if (position == "beforeend") { else if (position === "beforeend") {
this.appendChild(window.document.createTextNode(html)) this.appendChild(window.document.createTextNode(html))
} }
}, },
@ -104,7 +104,8 @@ mock.window = (function() {
this.childNodes.splice(index, 1) this.childNodes.splice(index, 1)
child.parentNode = null child.parentNode = null
} }
//getElementsByTagName is only used by JSONP tests, it's not required by Mithril // getElementsByTagName is only used by JSONP tests, it's not required by
// Mithril
window.document.getElementsByTagName = function(name){ window.document.getElementsByTagName = function(name){
name = name.toLowerCase(); name = name.toLowerCase();
var out = []; var out = [];
@ -112,12 +113,13 @@ mock.window = (function() {
var traverse = function(node){ var traverse = function(node){
if(node.childNodes && node.childNodes.length > 0){ if(node.childNodes && node.childNodes.length > 0){
node.childNodes.map(function(curr){ node.childNodes.map(function(curr){
if(curr.nodeName.toLowerCase() === name) if (curr.nodeName.toLowerCase() === name) {
out.push(curr); out.push(curr);
}
traverse(curr); traverse(curr);
}); });
} }
}; }
traverse(window.document); traverse(window.document);
return out; return out;
@ -156,13 +158,13 @@ mock.window = (function() {
request.$instances = [] request.$instances = []
return request return request
}()) }())
window.location = {search: "", pathname: "", hash: ""}, window.location = {search: "", pathname: "", hash: ""}
window.history = {} window.history = {}
window.history.$$length = 0 window.history.$$length = 0
window.history.pushState = function(data, title, url) { window.history.pushState = function(data, title, url) {
window.history.$$length++ window.history.$$length++
window.location.pathname = window.location.search = window.location.hash = url window.location.pathname = window.location.search = window.location.hash = url
}, }
window.history.replaceState = function(data, title, url) { window.history.replaceState = function(data, title, url) {
window.location.pathname = window.location.search = window.location.hash = url window.location.pathname = window.location.search = window.location.hash = url
} }