|
|
@@ -1,5 +1,5 @@
|
|
|
/*!
|
|
|
- * Vue.js v2.0.0-beta.7
|
|
|
+ * Vue.js v2.0.0-beta.8
|
|
|
* (c) 2014-2016 Evan You
|
|
|
* Released under the MIT License.
|
|
|
*/
|
|
|
@@ -1341,15 +1341,10 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // in case the child is also an abstract component, e.g. <transition-control>
|
|
|
- // we want to recrusively retrieve the real component to be rendered
|
|
|
- function getRealChild(vnode) {
|
|
|
- var compOptions = vnode && vnode.componentOptions;
|
|
|
- if (compOptions && compOptions.Ctor.options.abstract) {
|
|
|
- return getRealChild(compOptions.propsData && compOptions.propsData.child);
|
|
|
- } else {
|
|
|
- return vnode;
|
|
|
- }
|
|
|
+ function getFirstComponentChild(children) {
|
|
|
+ return children && children.filter(function (c) {
|
|
|
+ return c && c.componentOptions;
|
|
|
+ })[0];
|
|
|
}
|
|
|
|
|
|
function mergeVNodeHook(def, key, hook) {
|
|
|
@@ -1535,8 +1530,9 @@
|
|
|
vm.$options._parentListeners = listeners;
|
|
|
vm._updateListeners(listeners, oldListeners);
|
|
|
}
|
|
|
- // force udpate if has children
|
|
|
+ // resolve slots + force update if has children
|
|
|
if (hasChildren) {
|
|
|
+ vm.$slots = resolveSlots(renderChildren);
|
|
|
vm.$forceUpdate();
|
|
|
}
|
|
|
};
|
|
|
@@ -1897,7 +1893,7 @@
|
|
|
vm.$vnode = null; // the placeholder node in parent tree
|
|
|
vm._vnode = null; // the root of the child tree
|
|
|
vm._staticTrees = null;
|
|
|
- vm.$slots = {};
|
|
|
+ vm.$slots = resolveSlots(vm.$options._renderChildren);
|
|
|
// bind the public createElement fn to this instance
|
|
|
// so that we get proper render context inside it.
|
|
|
vm.$createElement = bind(createElement, vm);
|
|
|
@@ -1916,7 +1912,6 @@
|
|
|
var _vm$$options = vm.$options;
|
|
|
var render = _vm$$options.render;
|
|
|
var staticRenderFns = _vm$$options.staticRenderFns;
|
|
|
- var _renderChildren = _vm$$options._renderChildren;
|
|
|
var _parentVnode = _vm$$options._parentVnode;
|
|
|
|
|
|
|
|
|
@@ -1926,9 +1921,6 @@
|
|
|
// set parent vnode. this allows render functions to have access
|
|
|
// to the data on the placeholder node.
|
|
|
vm.$vnode = _parentVnode;
|
|
|
- // resolve slots. becaues slots are rendered in parent scope,
|
|
|
- // we set the activeInstance to parent.
|
|
|
- vm.$slots = resolveSlots(_renderChildren);
|
|
|
// render self
|
|
|
var vnode = void 0;
|
|
|
try {
|
|
|
@@ -1972,11 +1964,23 @@
|
|
|
Vue.prototype._n = toNumber;
|
|
|
|
|
|
// render static tree by index
|
|
|
- Vue.prototype._m = function renderStatic(index) {
|
|
|
+ Vue.prototype._m = function renderStatic(index, isInFor) {
|
|
|
var tree = this._staticTrees[index];
|
|
|
- if (!tree) {
|
|
|
- tree = this._staticTrees[index] = this.$options.staticRenderFns[index].call(this._renderProxy);
|
|
|
+ // if has already-rendered static tree and not inside v-for,
|
|
|
+ // we can reuse the same tree by indentity.
|
|
|
+ if (tree && !isInFor) {
|
|
|
+ return tree;
|
|
|
+ }
|
|
|
+ // otherwise, render a fresh tree.
|
|
|
+ tree = this._staticTrees[index] = this.$options.staticRenderFns[index].call(this._renderProxy);
|
|
|
+ if (Array.isArray(tree)) {
|
|
|
+ for (var i = 0; i < tree.length; i++) {
|
|
|
+ tree[i].isStatic = true;
|
|
|
+ tree[i].key = '__static__' + index + '_' + i;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
tree.isStatic = true;
|
|
|
+ tree.key = '__static__' + index;
|
|
|
}
|
|
|
return tree;
|
|
|
};
|
|
|
@@ -2027,12 +2031,12 @@
|
|
|
value = toObject(value);
|
|
|
}
|
|
|
var data = vnode.data;
|
|
|
- for (var key in value) {
|
|
|
- if (key === 'class' || key === 'style') {
|
|
|
- data[key] = value[key];
|
|
|
+ for (var _key in value) {
|
|
|
+ if (_key === 'class' || _key === 'style') {
|
|
|
+ data[_key] = value[_key];
|
|
|
} else {
|
|
|
- var hash = asProp || config.mustUseProp(key) ? data.domProps || (data.domProps = {}) : data.attrs || (data.attrs = {});
|
|
|
- hash[key] = value[key];
|
|
|
+ var hash = asProp || config.mustUseProp(_key) ? data.domProps || (data.domProps = {}) : data.attrs || (data.attrs = {});
|
|
|
+ hash[_key] = value[_key];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -2808,29 +2812,26 @@
|
|
|
var KeepAlive = {
|
|
|
name: 'keep-alive',
|
|
|
abstract: true,
|
|
|
- props: {
|
|
|
- child: Object
|
|
|
- },
|
|
|
created: function created() {
|
|
|
this.cache = Object.create(null);
|
|
|
},
|
|
|
render: function render() {
|
|
|
- var rawChild = this.child;
|
|
|
- var realChild = getRealChild(this.child);
|
|
|
- if (realChild && realChild.componentOptions) {
|
|
|
- var opts = realChild.componentOptions;
|
|
|
+ var vnode = getFirstComponentChild(this.$slots.default);
|
|
|
+ if (vnode && vnode.componentOptions) {
|
|
|
+ var opts = vnode.componentOptions;
|
|
|
+ var key = vnode.key == null
|
|
|
// same constructor may get registered as different local components
|
|
|
// so cid alone is not enough (#3269)
|
|
|
- var key = opts.Ctor.cid + '::' + opts.tag;
|
|
|
+ ? opts.Ctor.cid + '::' + opts.tag : vnode.key;
|
|
|
if (this.cache[key]) {
|
|
|
- var child = realChild.child = this.cache[key].child;
|
|
|
- realChild.elm = this.$el = child.$el;
|
|
|
+ var child = vnode.child = this.cache[key].child;
|
|
|
+ vnode.elm = this.$el = child.$el;
|
|
|
} else {
|
|
|
- this.cache[key] = realChild;
|
|
|
+ this.cache[key] = vnode;
|
|
|
}
|
|
|
- realChild.data.keepAlive = true;
|
|
|
+ vnode.data.keepAlive = true;
|
|
|
}
|
|
|
- return rawChild;
|
|
|
+ return vnode;
|
|
|
},
|
|
|
destroyed: function destroyed() {
|
|
|
for (var key in this.cache) {
|
|
|
@@ -2883,7 +2884,7 @@
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- Vue.version = '2.0.0-beta.7';
|
|
|
+ Vue.version = '2.0.0-beta.8';
|
|
|
|
|
|
// attributes that should be using props for binding
|
|
|
var mustUseProp = makeMap('value,selected,checked,muted');
|
|
|
@@ -3044,8 +3045,10 @@
|
|
|
var isIE9 = UA$1 && UA$1.indexOf('msie 9.0') > 0;
|
|
|
var isAndroid = UA$1 && UA$1.indexOf('android') > 0;
|
|
|
|
|
|
- // some browsers, e.g. PhantomJS, encodes angular brackets
|
|
|
- // inside attribute values when retrieving innerHTML.
|
|
|
+ // According to
|
|
|
+ // https://w3c.github.io/DOM-Parsing/#dfn-serializing-an-attribute-value
|
|
|
+ // when serializing innerHTML, <, >, ", & should be encoded as entities.
|
|
|
+ // However, only some browsers, e.g. PhantomJS, encodes < and >.
|
|
|
// this causes problems with the in-browser parser.
|
|
|
var shouldDecodeTags = inBrowser ? function () {
|
|
|
var div = document.createElement('div');
|
|
|
@@ -3149,9 +3152,6 @@ var nodeOps = Object.freeze({
|
|
|
}
|
|
|
|
|
|
function sameVnode(vnode1, vnode2) {
|
|
|
- if (vnode1.isStatic || vnode2.isStatic) {
|
|
|
- return vnode1 === vnode2;
|
|
|
- }
|
|
|
return vnode1.key === vnode2.key && vnode1.tag === vnode2.tag && vnode1.isComment === vnode2.isComment && !vnode1.data === !vnode2.data;
|
|
|
}
|
|
|
|
|
|
@@ -3393,8 +3393,8 @@ var nodeOps = Object.freeze({
|
|
|
newStartVnode = newCh[++newStartIdx];
|
|
|
} else {
|
|
|
if (isUndef(oldKeyToIdx)) oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
|
|
|
- idxInOld = isDef(newStartVnode.key) ? oldKeyToIdx[newStartVnode.key] : newStartVnode.isStatic ? oldCh.indexOf(newStartVnode) : null;
|
|
|
- if (isUndef(idxInOld) || idxInOld === -1) {
|
|
|
+ idxInOld = isDef(newStartVnode.key) ? oldKeyToIdx[newStartVnode.key] : null;
|
|
|
+ if (isUndef(idxInOld)) {
|
|
|
// New element
|
|
|
nodeOps.insertBefore(parentElm, createElm(newStartVnode, insertedVnodeQueue), oldStartVnode.elm);
|
|
|
newStartVnode = newCh[++newStartIdx];
|
|
|
@@ -3426,7 +3426,13 @@ var nodeOps = Object.freeze({
|
|
|
}
|
|
|
|
|
|
function patchVnode(oldVnode, vnode, insertedVnodeQueue, removeOnly) {
|
|
|
- if (oldVnode === vnode) return;
|
|
|
+ if (oldVnode === vnode) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (vnode.isStatic && oldVnode.isStatic && vnode.key === oldVnode.key) {
|
|
|
+ vnode.elm = oldVnode.elm;
|
|
|
+ return;
|
|
|
+ }
|
|
|
var i = void 0,
|
|
|
hook = void 0;
|
|
|
var hasData = isDef(i = vnode.data);
|
|
|
@@ -4081,7 +4087,7 @@ var nodeOps = Object.freeze({
|
|
|
}
|
|
|
|
|
|
/* istanbul ignore if */
|
|
|
- if (el._enterCb) {
|
|
|
+ if (el._enterCb || el.nodeType !== 1) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -4185,7 +4191,7 @@ var nodeOps = Object.freeze({
|
|
|
}
|
|
|
|
|
|
/* istanbul ignore if */
|
|
|
- if (el._leaveCb) {
|
|
|
+ if (el._leaveCb || el.nodeType !== 1) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -4438,7 +4444,10 @@ var nodeOps = Object.freeze({
|
|
|
},
|
|
|
update: function update(el, _ref2, vnode) {
|
|
|
var value = _ref2.value;
|
|
|
+ var oldValue = _ref2.oldValue;
|
|
|
|
|
|
+ /* istanbul ignore if */
|
|
|
+ if (value === oldValue) return;
|
|
|
vnode = locateNode(vnode);
|
|
|
var transition = vnode.data && vnode.data.transition;
|
|
|
if (transition && !isIE9) {
|
|
|
@@ -4475,6 +4484,17 @@ var nodeOps = Object.freeze({
|
|
|
appearActiveClass: String
|
|
|
};
|
|
|
|
|
|
+ // in case the child is also an abstract component, e.g. <keep-alive>
|
|
|
+ // we want to recrusively retrieve the real component to be rendered
|
|
|
+ function getRealChild(vnode) {
|
|
|
+ var compOptions = vnode && vnode.componentOptions;
|
|
|
+ if (compOptions && compOptions.Ctor.options.abstract) {
|
|
|
+ return getRealChild(getFirstComponentChild(compOptions.children));
|
|
|
+ } else {
|
|
|
+ return vnode;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
function extractTransitionData(comp) {
|
|
|
var data = {};
|
|
|
var options = comp.$options;
|
|
|
@@ -4536,8 +4556,11 @@ var nodeOps = Object.freeze({
|
|
|
// use getRealChild() to ignore abstract components e.g. keep-alive
|
|
|
var child = getRealChild(rawChild);
|
|
|
/* istanbul ignore if */
|
|
|
- if (!child) return;
|
|
|
- child.key = child.key || '__v' + (child.tag + this._uid) + '__';
|
|
|
+ if (!child) {
|
|
|
+ return rawChild;
|
|
|
+ }
|
|
|
+
|
|
|
+ child.key = child.key == null ? '__v' + (child.tag + this._uid) + '__' : child.key;
|
|
|
var data = (child.data || (child.data = {})).transition = extractTransitionData(this);
|
|
|
var oldRawChild = this._vnode;
|
|
|
var oldChild = getRealChild(oldRawChild);
|
|
|
@@ -4778,12 +4801,13 @@ var nodeOps = Object.freeze({
|
|
|
var ampRE = /&/g;
|
|
|
var ltRE = /</g;
|
|
|
var gtRE = />/g;
|
|
|
+ var quoteRE = /"/g;
|
|
|
|
|
|
function decodeAttr(value, shouldDecodeTags) {
|
|
|
if (shouldDecodeTags) {
|
|
|
value = value.replace(ltRE, '<').replace(gtRE, '>');
|
|
|
}
|
|
|
- return value.replace(ampRE, '&');
|
|
|
+ return value.replace(ampRE, '&').replace(quoteRE, '"');
|
|
|
}
|
|
|
|
|
|
function parseHTML(html, options) {
|
|
|
@@ -5520,9 +5544,6 @@ var nodeOps = Object.freeze({
|
|
|
if (binding = getBindingAttr(el, 'is')) {
|
|
|
el.component = binding;
|
|
|
}
|
|
|
- if (getAndRemoveAttr(el, 'keep-alive') != null) {
|
|
|
- el.keepAlive = true;
|
|
|
- }
|
|
|
if (getAndRemoveAttr(el, 'inline-template') != null) {
|
|
|
el.inlineTemplate = true;
|
|
|
}
|
|
|
@@ -5668,7 +5689,7 @@ var nodeOps = Object.freeze({
|
|
|
// first pass: mark all non-static nodes.
|
|
|
markStatic(root);
|
|
|
// second pass: mark static roots.
|
|
|
- markStaticRoots(root);
|
|
|
+ markStaticRoots(root, false);
|
|
|
}
|
|
|
|
|
|
function genStaticKeys$1(keys) {
|
|
|
@@ -5688,14 +5709,17 @@ var nodeOps = Object.freeze({
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- function markStaticRoots(node) {
|
|
|
- if (node.type === 1 && (node.once || node.static)) {
|
|
|
- node.staticRoot = true;
|
|
|
- return;
|
|
|
- }
|
|
|
- if (node.children) {
|
|
|
- for (var i = 0, l = node.children.length; i < l; i++) {
|
|
|
- markStaticRoots(node.children[i]);
|
|
|
+ function markStaticRoots(node, isInFor) {
|
|
|
+ if (node.type === 1) {
|
|
|
+ if (node.once || node.static) {
|
|
|
+ node.staticRoot = true;
|
|
|
+ node.staticInFor = isInFor;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (node.children) {
|
|
|
+ for (var i = 0, l = node.children.length; i < l; i++) {
|
|
|
+ markStaticRoots(node.children[i], !!node.for);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -5802,7 +5826,6 @@ var nodeOps = Object.freeze({
|
|
|
dataGenFns = pluckModuleFunction(options.modules, 'genData');
|
|
|
platformDirectives$1 = options.directives || {};
|
|
|
var code = ast ? genElement(ast) : '_h("div")';
|
|
|
- // console.log(code)
|
|
|
staticRenderFns = prevStaticRenderFns;
|
|
|
return {
|
|
|
render: 'with(this){return ' + code + '}',
|
|
|
@@ -5815,7 +5838,7 @@ var nodeOps = Object.freeze({
|
|
|
// hoist static sub-trees out
|
|
|
el.staticProcessed = true;
|
|
|
staticRenderFns.push('with(this){return ' + genElement(el) + '}');
|
|
|
- return '_m(' + (staticRenderFns.length - 1) + ')';
|
|
|
+ return '_m(' + (staticRenderFns.length - 1) + (el.staticInFor ? ',true' : '') + ')';
|
|
|
} else if (el.for && !el.forProcessed) {
|
|
|
return genFor(el);
|
|
|
} else if (el.if && !el.ifProcessed) {
|
|
|
@@ -5840,10 +5863,6 @@ var nodeOps = Object.freeze({
|
|
|
for (var i = 0; i < transforms$1.length; i++) {
|
|
|
code = transforms$1[i](el, code);
|
|
|
}
|
|
|
- // check keep-alive
|
|
|
- if (el.keepAlive) {
|
|
|
- code = '_h("KeepAlive",{props:{child:' + code + '}})';
|
|
|
- }
|
|
|
return code;
|
|
|
}
|
|
|
}
|