From 5e212336d0cbf8a341dbd5b5bf9a8c202c089341 Mon Sep 17 00:00:00 2001 From: Kabir Shah Date: Sat, 15 Apr 2017 09:08:17 -0700 Subject: [PATCH] remove checks for both vnodes/nodes are null --- dist/moon.js | 12 ++++-------- dist/moon.min.js | 2 +- src/util/vdom.js | 12 ++++-------- 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/dist/moon.js b/dist/moon.js index a47610fc..30718dab 100644 --- a/dist/moon.js +++ b/dist/moon.js @@ -661,9 +661,7 @@ var hydrate = function (node, vnode, parent, instance) { var nodeName = node ? node.nodeName.toLowerCase() : null; - if (node === null && vnode === null) { - return null; - } else if (node === null) { + if (node === null) { // No node, create one var newNode = createNodeFromVNode(vnode, instance); appendChild(newNode, vnode, parent); @@ -735,17 +733,15 @@ }; /** - * Diffs Node and a VNode, and applies Changes - * @param {Object} node + * Diffs VNodes, and applies Changes + * @param {Object} oldVNode * @param {Object} vnode * @param {Object} parent * @param {Object} instance * @return {Number} patch type */ var diff = function (oldVNode, vnode, parent, instance) { - if (oldVNode === null && vnode === null) { - return PATCH.SKIP; - } else if (oldVNode === null) { + if (oldVNode === null) { // No Node, append a node appendChild(createNodeFromVNode(vnode, instance), vnode, parent); diff --git a/dist/moon.min.js b/dist/moon.min.js index f456eea0..d2bae678 100644 --- a/dist/moon.min.js +++ b/dist/moon.min.js @@ -4,4 +4,4 @@ * Released under the MIT License * http://moonjs.ga */ -!function(e,t){"object"==typeof module&&module.exports?module.exports=t():e.Moon=t()}(this,function(){"use strict";function e(e){this.instance=e,this.cache={},this.setters={},this.clear={},this.target=null,this.map={}}function t(t){this.$opts=t||{};var r=this;this.$id=a++,this.$name=this.$opts.name||"root",this.$data=this.$opts.data||{},this.$render=this.$opts.render||b,this.$hooks=this.$opts.hooks||{};var n=this.$opts.methods;void 0!==n&&s(r,n),this.$events={},this.$dom={},this.$observer=new e(this),this.$destroyed=!0,this.$queued=!1;var i=this.$opts.computed;void 0!==i&&l(this,i),this.init()}var r={},n={},i={},o={stop:"event.stopPropagation();",prevent:"event.preventDefault();",ctrl:"if(!event.ctrlKey) {return;};",shift:"if(!event.shiftKey) {return;};",alt:"if(!event.altKey) {return;};",enter:"if(event.keyCode !== 13) {return;};"},a=0,s=function(e,t){for(var r in t)!function(t,r){e.$data[t]=function(){return r.apply(e,arguments)}}(r,t[r])},l=function(e,t){for(var r in t)!function(r){var n=e.$observer;n.observe(r),Object.defineProperty(e.$data,r,{get:function(){var i=null;return void 0===n.cache[r]?(n.target=r,i=t[r].get.call(e),n.target=null,n.cache[r]=i):i=n.cache[r],i},set:b});var i=null;void 0!==(i=t[r].set)&&(n.setters[r]=i)}(r)};e.prototype.observe=function(e){var t=this;this.clear[e]=function(){t.cache[e]=void 0}},e.prototype.notify=function(e,t){var r=null;if(void 0!==(r=this.map[e]))for(var n=0;ns?a:s,c=0;c"===o||" "===o)break;i+=o,n++}var a={type:"tag",value:i};return e.tokens.push(a),e.current=n,a},z=function(e,t){for(var r=t.input,n=r.length,i=t.current,o=r.charAt(i),a=r.charAt(i+1),s=function(){i++,o=r.charAt(i),a=r.charAt(i+1)},l={};i"!==o&&("/"!==o||">"!==a);)if(" "!==o){for(var u="",c=!1;i"===o||"/"===o||">"===a){c=!0;break}u+=o,s()}var p={name:u,value:"",meta:{}};if(c)l[u]=p;else{s();var f=" ";for("'"!==o&&'"'!==o||(f=o,s());i1&&(s=l.shift(),a=l.join("(").slice(0,-1));var u="";n.shift();for(var c=0;cs?a:s,c=0;c"===o||" "===o)break;i+=o,n++}var a={type:"tag",value:i};return e.tokens.push(a),e.current=n,a},z=function(e,t){for(var r=t.input,n=r.length,i=t.current,o=r.charAt(i),a=r.charAt(i+1),s=function(){i++,o=r.charAt(i),a=r.charAt(i+1)},l={};i"!==o&&("/"!==o||">"!==a);)if(" "!==o){for(var u="",c=!1;i"===o||"/"===o||">"===a){c=!0;break}u+=o,s()}var p={name:u,value:"",meta:{}};if(c)l[u]=p;else{s();var f=" ";for("'"!==o&&'"'!==o||(f=o,s());i1&&(s=l.shift(),a=l.join("(").slice(0,-1));var u="";n.shift();for(var c=0;c