Fix redundancy (#2213)

* Remove redundant empty fragment return

* Rebuild bundles

* Update changelog
This commit is contained in:
Isiah Meadows 2018-09-19 01:23:33 -04:00 committed by GitHub
parent 8f617967ea
commit ad5118165c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 13 deletions

View file

@ -27,6 +27,7 @@
- hyperscript: when attributes have a `null` or `undefined` value, they are treated as if they were absent. [#1773](https://github.com/MithrilJS/mithril.js/issues/1773) ([#2174](https://github.com/MithrilJS/mithril.js/pull/2174))
- hyperscript: when an attribute is defined on both the first and second argument (as a CSS selector and an `attrs` field, respectively), the latter takes precedence, except for `class` attributes that are still added together. [#2172](https://github.com/MithrilJS/mithril.js/issues/2172) ([#2174](https://github.com/MithrilJS/mithril.js/pull/2174))
- stream: when a stream conditionally returns HALT, dependant stream will also end ([#2200](https://github.com/MithrilJS/mithril.js/pull/2200))
- render: remove some redundancy within the component initialization code ([#2213](https://github.com/MithrilJS/mithril.js/pull/2213))
#### News

View file

@ -410,7 +410,6 @@ var _9 = function($window, Promise) {
var requestService = _9(window, PromisePolyfill)
var coreRenderer = function($window) {
var $doc = $window.document
var $emptyFragment = $doc.createDocumentFragment()
var nameSpace = {
svg: "http://www.w3.org/2000/svg",
math: "http://www.w3.org/1998/Math/MathML"
@ -530,12 +529,12 @@ var coreRenderer = function($window) {
if (typeof vnode.tag.view === "function") {
vnode.state = Object.create(vnode.tag)
sentinel = vnode.state.view
if (sentinel.$$reentrantLock$$ != null) return $emptyFragment
if (sentinel.$$reentrantLock$$ != null) return
sentinel.$$reentrantLock$$ = true
} else {
vnode.state = void 0
sentinel = vnode.tag
if (sentinel.$$reentrantLock$$ != null) return $emptyFragment
if (sentinel.$$reentrantLock$$ != null) return
sentinel.$$reentrantLock$$ = true
vnode.state = (vnode.tag.prototype != null && typeof vnode.tag.prototype.view === "function") ? new vnode.tag(vnode) : vnode.tag(vnode)
}

14
mithril.min.js vendored
View file

@ -34,13 +34,13 @@ a.domSize||1;if(1<b)for(var f=a.dom;--b;){var e=f.nextSibling,m=e.parentNode;nul
typeof d)){if("o"===b[0]&&"n"===b[1])return U(a,b,d);if("xlink:"===b.slice(0,6))a.dom.setAttributeNS("http://www.w3.org/1999/xlink",b.slice(6),d);else if("style"===b)T(a.dom,c,d);else if(!(b in a.dom)||S(b)||void 0!==e||a.attrs.is||-1<a.tag.indexOf("-"))"boolean"===typeof d?d?a.dom.setAttribute(b,""):a.dom.removeAttribute(b):a.dom.setAttribute("className"===b?"class":b,d);else{if("value"===b&&(e=""+d,("input"===a.tag||"textarea"===a.tag)&&a.dom.value===e&&a.dom===D.activeElement||"select"===a.tag&&
null!==c&&a.dom.value===e||"option"===a.tag&&null!==c&&a.dom.value===e))return;"input"===a.tag&&"type"===b?a.dom.setAttribute(b,d):a.dom[b]=d}}}function w(a){return"oninit"===a||"oncreate"===a||"onupdate"===a||"onremove"===a||"onbeforeremove"===a||"onbeforeupdate"===a}function S(a){return"href"===a||"list"===a||"form"===a||"width"===a||"height"===a}function T(a,b,c){if(null!=b&&null!=c&&"object"===typeof b&&"object"===typeof c&&c!==b){for(var d in c)c[d]!==b[d]&&(a.style[d]=c[d]);for(d in b)d in c||
(a.style[d]="")}else if(b===c&&(a.style.cssText="",b=null),null==c)a.style.cssText="";else if("string"===typeof c)a.style.cssText=c;else for(d in"string"===typeof b&&(a.style.cssText=""),c)a.style[d]=c[d]}function M(){}function U(a,b,c){null!=a.events?a.events[b]!==c&&(null==c||"function"!==typeof c&&"object"!==typeof c?(null!=a.events[b]&&a.dom.removeEventListener(b.slice(2),a.events,!1),a.events[b]=void 0):(null==a.events[b]&&a.dom.addEventListener(b.slice(2),a.events,!1),a.events[b]=c)):null==
c||"function"!==typeof c&&"object"!==typeof c||(a.events=new M,a.dom.addEventListener(b.slice(2),a.events,!1),a.events[b]=c)}function N(a,b,c){"function"===typeof a.oninit&&e.call(a.oninit,b);"function"===typeof a.oncreate&&c.push(e.bind(a.oncreate,b))}function L(a,b,c){"function"===typeof a.onupdate&&c.push(e.bind(a.onupdate,b))}var D=a.document;D.createDocumentFragment();var H={svg:"http://www.w3.org/2000/svg",math:"http://www.w3.org/1998/Math/MathML"},I,J={caption:"table",thead:"table",tbody:"table",
tfoot:"table",tr:"tbody",th:"tr",td:"tr",colgroup:"table",col:"colgroup"};M.prototype=Object.create(null);M.prototype.handleEvent=function(a){var b=this["on"+a.type],c;"function"===typeof b?c=b.call(a.target,a):"function"===typeof b.handleEvent&&b.handleEvent(a);"function"===typeof I&&I.call(a.target,a);!1===c&&(a.preventDefault(),a.stopPropagation())};return{render:function(a,b){if(!a)throw Error("Ensure the DOM element being passed to m.route/m.mount/m.render is not undefined.");var c=[],d=D.activeElement,
e=a.namespaceURI;null==a.vnodes&&(a.textContent="");Array.isArray(b)||(b=[b]);k(a,a.vnodes,z.normalizeChildren(b),c,null,"http://www.w3.org/1999/xhtml"===e?void 0:e);a.vnodes=b;null!=d&&D.activeElement!==d&&"function"===typeof d.focus&&d.focus();for(d=0;d<c.length;d++)c[d]()},setEventCallback:function(a){return I=a}}},J=function(a,d){function e(a){a=h.indexOf(a);-1<a&&h.splice(a,2)}function g(){if(k)throw Error("Nested m.redraw.sync() call");k=!0;for(var a=1;a<h.length;a+=2)try{h[a]()}catch(l){"undefined"!==
typeof console&&console.error(l)}k=!1}var q=V(a);q.setEventCallback(function(a){!1===a.redraw?a.redraw=void 0:n()});var h=[],k=!1,n=(d||X)(g);n.sync=g;return{subscribe:function(a,d){e(a);h.push(a,d)},unsubscribe:e,redraw:n,render:q.render}}(window);O.setCompletionCallback(J.redraw);w.mount=function(a){return function(d,e){if(null===e)a.render(d,[]),a.unsubscribe(d);else{if(null==e.view&&"function"!==typeof e)throw Error("m.mount(element, component) expects a component, not a vnode");var g=function(){a.render(d,
z(e))};a.subscribe(d,g);g()}}}(J);var ba=p,P=function(a){if(""===a||null==a)return{};"?"===a.charAt(0)&&(a=a.slice(1));a=a.split("&");for(var d={},e={},g=0;g<a.length;g++){var q=a[g].split("="),h=decodeURIComponent(q[0]);q=2===q.length?decodeURIComponent(q[1]):"";"true"===q?q=!0:"false"===q&&(q=!1);var k=h.split(/\]\[?|\[/),n=d;-1<h.indexOf("[")&&k.pop();for(var m=0;m<k.length;m++){h=k[m];var l=k[m+1];l=""==l||!isNaN(parseInt(l,10));var p=m===k.length-1;""===h&&(h=k.slice(0,m).join(),null==e[h]&&
(e[h]=0),h=e[h]++);null==n[h]&&(n[h]=p?q:l?[]:{});n=n[h]}}return d},ca=function(a){function d(d){var e=a.location[d].replace(/(?:%[a-f89][a-f0-9])+/gim,decodeURIComponent);"pathname"===d&&"/"!==e[0]&&(e="/"+e);return e}function e(a){return function(){null==k&&(k=h(function(){k=null;a()}))}}function g(a,d,e){var c=a.indexOf("?"),g=a.indexOf("#"),k=-1<c?c:-1<g?g:a.length;if(-1<c){c=P(a.slice(c+1,-1<g?g:a.length));for(var h in c)d[h]=c[h]}if(-1<g)for(h in d=P(a.slice(g+1)),d)e[h]=d[h];return a.slice(0,
k)}var q="function"===typeof a.history.pushState,h="function"===typeof setImmediate?setImmediate:setTimeout,k,n={prefix:"#!",getPath:function(){switch(n.prefix.charAt(0)){case "#":return d("hash").slice(n.prefix.length);case "?":return d("search").slice(n.prefix.length)+d("hash");default:return d("pathname").slice(n.prefix.length)+d("search")+d("hash")}},setPath:function(d,e,h){var c={},k={};d=g(d,c,k);if(null!=e){for(var m in e)c[m]=e[m];d=d.replace(/:([^\/]+)/g,function(a,d){delete c[d];return e[d]})}(m=
c||"function"!==typeof c&&"object"!==typeof c||(a.events=new M,a.dom.addEventListener(b.slice(2),a.events,!1),a.events[b]=c)}function N(a,b,c){"function"===typeof a.oninit&&e.call(a.oninit,b);"function"===typeof a.oncreate&&c.push(e.bind(a.oncreate,b))}function L(a,b,c){"function"===typeof a.onupdate&&c.push(e.bind(a.onupdate,b))}var D=a.document,H={svg:"http://www.w3.org/2000/svg",math:"http://www.w3.org/1998/Math/MathML"},I,J={caption:"table",thead:"table",tbody:"table",tfoot:"table",tr:"tbody",
th:"tr",td:"tr",colgroup:"table",col:"colgroup"};M.prototype=Object.create(null);M.prototype.handleEvent=function(a){var b=this["on"+a.type],c;"function"===typeof b?c=b.call(a.target,a):"function"===typeof b.handleEvent&&b.handleEvent(a);"function"===typeof I&&I.call(a.target,a);!1===c&&(a.preventDefault(),a.stopPropagation())};return{render:function(a,b){if(!a)throw Error("Ensure the DOM element being passed to m.route/m.mount/m.render is not undefined.");var c=[],d=D.activeElement,e=a.namespaceURI;
null==a.vnodes&&(a.textContent="");Array.isArray(b)||(b=[b]);k(a,a.vnodes,z.normalizeChildren(b),c,null,"http://www.w3.org/1999/xhtml"===e?void 0:e);a.vnodes=b;null!=d&&D.activeElement!==d&&"function"===typeof d.focus&&d.focus();for(d=0;d<c.length;d++)c[d]()},setEventCallback:function(a){return I=a}}},J=function(a,d){function e(a){a=h.indexOf(a);-1<a&&h.splice(a,2)}function g(){if(k)throw Error("Nested m.redraw.sync() call");k=!0;for(var a=1;a<h.length;a+=2)try{h[a]()}catch(l){"undefined"!==typeof console&&
console.error(l)}k=!1}var q=V(a);q.setEventCallback(function(a){!1===a.redraw?a.redraw=void 0:n()});var h=[],k=!1,n=(d||X)(g);n.sync=g;return{subscribe:function(a,d){e(a);h.push(a,d)},unsubscribe:e,redraw:n,render:q.render}}(window);O.setCompletionCallback(J.redraw);w.mount=function(a){return function(d,e){if(null===e)a.render(d,[]),a.unsubscribe(d);else{if(null==e.view&&"function"!==typeof e)throw Error("m.mount(element, component) expects a component, not a vnode");var g=function(){a.render(d,z(e))};
a.subscribe(d,g);g()}}}(J);var ba=p,P=function(a){if(""===a||null==a)return{};"?"===a.charAt(0)&&(a=a.slice(1));a=a.split("&");for(var d={},e={},g=0;g<a.length;g++){var q=a[g].split("="),h=decodeURIComponent(q[0]);q=2===q.length?decodeURIComponent(q[1]):"";"true"===q?q=!0:"false"===q&&(q=!1);var k=h.split(/\]\[?|\[/),n=d;-1<h.indexOf("[")&&k.pop();for(var m=0;m<k.length;m++){h=k[m];var l=k[m+1];l=""==l||!isNaN(parseInt(l,10));var p=m===k.length-1;""===h&&(h=k.slice(0,m).join(),null==e[h]&&(e[h]=0),
h=e[h]++);null==n[h]&&(n[h]=p?q:l?[]:{});n=n[h]}}return d},ca=function(a){function d(d){var e=a.location[d].replace(/(?:%[a-f89][a-f0-9])+/gim,decodeURIComponent);"pathname"===d&&"/"!==e[0]&&(e="/"+e);return e}function e(a){return function(){null==k&&(k=h(function(){k=null;a()}))}}function g(a,d,e){var c=a.indexOf("?"),g=a.indexOf("#"),k=-1<c?c:-1<g?g:a.length;if(-1<c){c=P(a.slice(c+1,-1<g?g:a.length));for(var h in c)d[h]=c[h]}if(-1<g)for(h in d=P(a.slice(g+1)),d)e[h]=d[h];return a.slice(0,k)}var q=
"function"===typeof a.history.pushState,h="function"===typeof setImmediate?setImmediate:setTimeout,k,n={prefix:"#!",getPath:function(){switch(n.prefix.charAt(0)){case "#":return d("hash").slice(n.prefix.length);case "?":return d("search").slice(n.prefix.length)+d("hash");default:return d("pathname").slice(n.prefix.length)+d("search")+d("hash")}},setPath:function(d,e,h){var c={},k={};d=g(d,c,k);if(null!=e){for(var m in e)c[m]=e[m];d=d.replace(/:([^\/]+)/g,function(a,d){delete c[d];return e[d]})}(m=
I(c))&&(d+="?"+m);(k=I(k))&&(d+="#"+k);q?(k=h?h.state:null,m=h?h.title:null,a.onpopstate(),h&&h.replace?a.history.replaceState(k,m,n.prefix+d):a.history.pushState(k,m,n.prefix+d)):a.location.href=n.prefix+d},defineRoutes:function(d,k,h){function c(){var c=n.getPath(),e={},m=g(c,e,e),l=a.history.state;if(null!=l)for(var q in l)e[q]=l[q];for(var p in d)if(l=new RegExp("^"+p.replace(/:[^\/]+?\.{3}/g,"(.*?)").replace(/:[^\/]+/g,"([^\\/]+)")+"/?$"),l.test(m)){m.replace(l,function(){for(var a=p.match(/:[^\/]+/g)||
[],g=[].slice.call(arguments,1,-2),h=0;h<a.length;h++)e[a[h].replace(/:|\./g,"")]=decodeURIComponent(g[h]);k(d[p],e,c,p)});return}h(c,e)}q?a.onpopstate=e(c):"#"===n.prefix.charAt(0)&&(a.onhashchange=c);c()}};return n};w.route=function(a,d){var e=ca(a),g=function(a){return a},p,h,k,n,m,l=function(a,l,q){function c(){null!=p&&d.render(a,p(z(h,k.key,k)))}if(null==a)throw Error("Ensure the DOM element that was passed to `m.route` is not undefined");var x=function(){c();x=d.redraw};d.subscribe(a,c);var w=
function(a){if(a!==l)e.setPath(l,null,{replace:!0});else throw Error("Could not resolve default route "+l);};e.defineRoutes(q,function(a,c,d){var e=m=function(a,l){e===m&&(h=null==l||"function"!==typeof l.view&&"function"!==typeof l?"div":l,k=c,n=d,m=null,p=(a.render||g).bind(a),x())};a.view||"function"===typeof a?e({},a):a.onmatch?ba.resolve(a.onmatch(c,d)).then(function(c){e(a,c)},w):e(a,"div")},w)};l.set=function(a,d,g){null!=m&&(g=g||{},g.replace=!0);m=null;e.setPath(a,d,g)};l.get=function(){return n};

View file

@ -4,7 +4,6 @@ var Vnode = require("../render/vnode")
module.exports = function($window) {
var $doc = $window.document
var $emptyFragment = $doc.createDocumentFragment()
var nameSpace = {
svg: "http://www.w3.org/2000/svg",
@ -135,12 +134,12 @@ module.exports = function($window) {
if (typeof vnode.tag.view === "function") {
vnode.state = Object.create(vnode.tag)
sentinel = vnode.state.view
if (sentinel.$$reentrantLock$$ != null) return $emptyFragment
if (sentinel.$$reentrantLock$$ != null) return
sentinel.$$reentrantLock$$ = true
} else {
vnode.state = void 0
sentinel = vnode.tag
if (sentinel.$$reentrantLock$$ != null) return $emptyFragment
if (sentinel.$$reentrantLock$$ != null) return
sentinel.$$reentrantLock$$ = true
vnode.state = (vnode.tag.prototype != null && typeof vnode.tag.prototype.view === "function") ? new vnode.tag(vnode) : vnode.tag(vnode)
}