function() {} -> noop
This commit is contained in:
parent
26a6664cd0
commit
4c1d7892aa
1 changed files with 15 additions and 15 deletions
30
mithril.js
30
mithril.js
|
|
@ -57,7 +57,7 @@ var m = (function app(window, undefined) {
|
||||||
else {
|
else {
|
||||||
cell.children = children
|
cell.children = children
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var attrName in attrs) {
|
for (var attrName in attrs) {
|
||||||
if (attrs.hasOwnProperty(attrName)) {
|
if (attrs.hasOwnProperty(attrName)) {
|
||||||
if (attrName === classAttrName && attrs[attrName] != null && attrs[attrName] !== "") {
|
if (attrName === classAttrName && attrs[attrName] != null && attrs[attrName] !== "") {
|
||||||
|
|
@ -68,7 +68,7 @@ var m = (function app(window, undefined) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (classes.length > 0) cell.attrs[classAttrName] = classes.join(" ");
|
if (classes.length > 0) cell.attrs[classAttrName] = classes.join(" ");
|
||||||
|
|
||||||
return cell
|
return cell
|
||||||
}
|
}
|
||||||
function build(parentElement, parentTag, parentCache, parentIndex, data, cached, shouldReattach, index, editable, namespace, configs) {
|
function build(parentElement, parentTag, parentCache, parentIndex, data, cached, shouldReattach, index, editable, namespace, configs) {
|
||||||
|
|
@ -124,7 +124,7 @@ var m = (function app(window, undefined) {
|
||||||
len = data.length
|
len = data.length
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var nodes = [], intact = cached.length === data.length, subArrayCount = 0;
|
var nodes = [], intact = cached.length === data.length, subArrayCount = 0;
|
||||||
|
|
||||||
//keys algorithm: sort elements without recreating them if keys are present
|
//keys algorithm: sort elements without recreating them if keys are present
|
||||||
|
|
@ -140,7 +140,7 @@ var m = (function app(window, undefined) {
|
||||||
existing[cached[i].attrs.key] = {action: DELETION, index: i}
|
existing[cached[i].attrs.key] = {action: DELETION, index: i}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var guid = 0
|
var guid = 0
|
||||||
for (var i = 0, len = data.length; i < len; i++) {
|
for (var i = 0, len = data.length; i < len; i++) {
|
||||||
if (data[i] && data[i].attrs && data[i].attrs.key != null) {
|
if (data[i] && data[i].attrs && data[i].attrs.key != null) {
|
||||||
|
|
@ -150,7 +150,7 @@ var m = (function app(window, undefined) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shouldMaintainIdentities) {
|
if (shouldMaintainIdentities) {
|
||||||
var keysDiffer = false
|
var keysDiffer = false
|
||||||
if (data.length != cached.length) keysDiffer = true
|
if (data.length != cached.length) keysDiffer = true
|
||||||
|
|
@ -160,7 +160,7 @@ var m = (function app(window, undefined) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keysDiffer) {
|
if (keysDiffer) {
|
||||||
for (var i = 0, len = data.length; i < len; i++) {
|
for (var i = 0, len = data.length; i < len; i++) {
|
||||||
if (data[i] && data[i].attrs) {
|
if (data[i] && data[i].attrs) {
|
||||||
|
|
@ -224,7 +224,7 @@ var m = (function app(window, undefined) {
|
||||||
}
|
}
|
||||||
if (!intact) {
|
if (!intact) {
|
||||||
//diff the array itself
|
//diff the array itself
|
||||||
|
|
||||||
//update the list of DOM nodes by collecting the nodes from each item
|
//update the list of DOM nodes by collecting the nodes from each item
|
||||||
for (var i = 0, len = data.length; i < len; i++) {
|
for (var i = 0, len = data.length; i < len; i++) {
|
||||||
if (cached[i] != null) nodes.push.apply(nodes, cached[i].nodes)
|
if (cached[i] != null) nodes.push.apply(nodes, cached[i].nodes)
|
||||||
|
|
@ -277,7 +277,7 @@ var m = (function app(window, undefined) {
|
||||||
if (data.attrs.xmlns) namespace = data.attrs.xmlns;
|
if (data.attrs.xmlns) namespace = data.attrs.xmlns;
|
||||||
else if (data.tag === "svg") namespace = "http://www.w3.org/2000/svg";
|
else if (data.tag === "svg") namespace = "http://www.w3.org/2000/svg";
|
||||||
else if (data.tag === "math") namespace = "http://www.w3.org/1998/Math/MathML";
|
else if (data.tag === "math") namespace = "http://www.w3.org/1998/Math/MathML";
|
||||||
|
|
||||||
if (isNew) {
|
if (isNew) {
|
||||||
if (data.attrs.is) node = namespace === undefined ? $document.createElement(data.tag, data.attrs.is) : $document.createElementNS(namespace, data.tag, data.attrs.is);
|
if (data.attrs.is) node = namespace === undefined ? $document.createElement(data.tag, data.attrs.is) : $document.createElementNS(namespace, data.tag, data.attrs.is);
|
||||||
else node = namespace === undefined ? $document.createElement(data.tag) : $document.createElementNS(namespace, data.tag);
|
else node = namespace === undefined ? $document.createElement(data.tag) : $document.createElementNS(namespace, data.tag);
|
||||||
|
|
@ -302,7 +302,7 @@ var m = (function app(window, undefined) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cached.children && !cached.children.nodes) cached.children.nodes = [];
|
if (cached.children && !cached.children.nodes) cached.children.nodes = [];
|
||||||
//edge case: setting value on <select> doesn't work before children exist, so set it again after children have been created
|
//edge case: setting value on <select> doesn't work before children exist, so set it again after children have been created
|
||||||
if (data.tag === "select" && "value" in data.attrs) setAttributes(node, data.tag, {value: data.attrs.value}, {}, namespace);
|
if (data.tag === "select" && "value" in data.attrs) setAttributes(node, data.tag, {value: data.attrs.value}, {}, namespace);
|
||||||
|
|
@ -569,7 +569,7 @@ var m = (function app(window, undefined) {
|
||||||
if (!root) throw new Error("Please ensure the DOM element exists before rendering a template into it.");
|
if (!root) throw new Error("Please ensure the DOM element exists before rendering a template into it.");
|
||||||
var index = roots.indexOf(root);
|
var index = roots.indexOf(root);
|
||||||
if (index < 0) index = roots.length;
|
if (index < 0) index = roots.length;
|
||||||
|
|
||||||
var isPrevented = false;
|
var isPrevented = false;
|
||||||
var event = {preventDefault: function() {
|
var event = {preventDefault: function() {
|
||||||
isPrevented = true;
|
isPrevented = true;
|
||||||
|
|
@ -583,17 +583,17 @@ var m = (function app(window, undefined) {
|
||||||
for (var i = 0, unloader; unloader = unloaders[i]; i++) unloader.controller.onunload = unloader.handler
|
for (var i = 0, unloader; unloader = unloaders[i]; i++) unloader.controller.onunload = unloader.handler
|
||||||
}
|
}
|
||||||
else unloaders = []
|
else unloaders = []
|
||||||
|
|
||||||
if (controllers[index] && typeof controllers[index].onunload === FUNCTION) {
|
if (controllers[index] && typeof controllers[index].onunload === FUNCTION) {
|
||||||
controllers[index].onunload(event)
|
controllers[index].onunload(event)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isPrevented) {
|
if (!isPrevented) {
|
||||||
m.redraw.strategy("all");
|
m.redraw.strategy("all");
|
||||||
m.startComputation();
|
m.startComputation();
|
||||||
roots[index] = root;
|
roots[index] = root;
|
||||||
if (arguments.length > 2) component = subcomponent(component, [].slice.call(arguments, 2))
|
if (arguments.length > 2) component = subcomponent(component, [].slice.call(arguments, 2))
|
||||||
var currentComponent = topComponent = component = component || {controller: function() {}};
|
var currentComponent = topComponent = component = component || {controller: noop};
|
||||||
var constructor = component.controller || noop
|
var constructor = component.controller || noop
|
||||||
var controller = new constructor;
|
var controller = new constructor;
|
||||||
//controllers may call m.mount recursively (via m.route redirects, for example)
|
//controllers may call m.mount recursively (via m.route redirects, for example)
|
||||||
|
|
@ -826,7 +826,7 @@ var m = (function app(window, undefined) {
|
||||||
}
|
}
|
||||||
function parseQueryString(str) {
|
function parseQueryString(str) {
|
||||||
if (str.charAt(0) === "?") str = str.substring(1);
|
if (str.charAt(0) === "?") str = str.substring(1);
|
||||||
|
|
||||||
var pairs = str.split("&"), params = {};
|
var pairs = str.split("&"), params = {};
|
||||||
for (var i = 0, len = pairs.length; i < len; i++) {
|
for (var i = 0, len = pairs.length; i < len; i++) {
|
||||||
var pair = pairs[i].split("=");
|
var pair = pairs[i].split("=");
|
||||||
|
|
@ -842,7 +842,7 @@ var m = (function app(window, undefined) {
|
||||||
}
|
}
|
||||||
m.route.buildQueryString = buildQueryString
|
m.route.buildQueryString = buildQueryString
|
||||||
m.route.parseQueryString = parseQueryString
|
m.route.parseQueryString = parseQueryString
|
||||||
|
|
||||||
function reset(root) {
|
function reset(root) {
|
||||||
var cacheKey = getCellCacheKey(root);
|
var cacheKey = getCellCacheKey(root);
|
||||||
clear(root.childNodes, cellCache[cacheKey]);
|
clear(root.childNodes, cellCache[cacheKey]);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue