|
@@ -1,5 +1,5 @@
|
|
|
/*!
|
|
/*!
|
|
|
- * Vue.js v1.0.19
|
|
|
|
|
|
|
+ * Vue.js v1.0.20
|
|
|
* (c) 2016 Evan You
|
|
* (c) 2016 Evan You
|
|
|
* Released under the MIT License.
|
|
* Released under the MIT License.
|
|
|
*/
|
|
*/
|
|
@@ -2042,6 +2042,24 @@ def(arrayProto, '$remove', function $remove(item) {
|
|
|
|
|
|
|
|
var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
|
|
var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * By default, when a reactive property is set, the new value is
|
|
|
|
|
+ * also converted to become reactive. However in certain cases, e.g.
|
|
|
|
|
+ * v-for scope alias and props, we don't want to force conversion
|
|
|
|
|
+ * because the value may be a nested value under a frozen data structure.
|
|
|
|
|
+ *
|
|
|
|
|
+ * So whenever we want to set a reactive property without forcing
|
|
|
|
|
+ * conversion on the new value, we wrap that call inside this function.
|
|
|
|
|
+ */
|
|
|
|
|
+
|
|
|
|
|
+var shouldConvert = true;
|
|
|
|
|
+
|
|
|
|
|
+function withoutConversion(fn) {
|
|
|
|
|
+ shouldConvert = false;
|
|
|
|
|
+ fn();
|
|
|
|
|
+ shouldConvert = true;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* Observer class that are attached to each observed
|
|
* Observer class that are attached to each observed
|
|
|
* object. Once attached, the observer converts target
|
|
* object. Once attached, the observer converts target
|
|
@@ -2179,7 +2197,7 @@ function observe(value, vm) {
|
|
|
var ob;
|
|
var ob;
|
|
|
if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
|
|
if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
|
|
|
ob = value.__ob__;
|
|
ob = value.__ob__;
|
|
|
- } else if ((isArray(value) || isPlainObject(value)) && Object.isExtensible(value) && !value._isVue) {
|
|
|
|
|
|
|
+ } else if (shouldConvert && (isArray(value) || isPlainObject(value)) && Object.isExtensible(value) && !value._isVue) {
|
|
|
ob = new Observer(value);
|
|
ob = new Observer(value);
|
|
|
}
|
|
}
|
|
|
if (ob && vm) {
|
|
if (ob && vm) {
|
|
@@ -2194,10 +2212,9 @@ function observe(value, vm) {
|
|
|
* @param {Object} obj
|
|
* @param {Object} obj
|
|
|
* @param {String} key
|
|
* @param {String} key
|
|
|
* @param {*} val
|
|
* @param {*} val
|
|
|
- * @param {Boolean} doNotObserve
|
|
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
-function defineReactive(obj, key, val, doNotObserve) {
|
|
|
|
|
|
|
+function defineReactive(obj, key, val) {
|
|
|
var dep = new Dep();
|
|
var dep = new Dep();
|
|
|
|
|
|
|
|
var property = Object.getOwnPropertyDescriptor(obj, key);
|
|
var property = Object.getOwnPropertyDescriptor(obj, key);
|
|
@@ -2209,11 +2226,7 @@ function defineReactive(obj, key, val, doNotObserve) {
|
|
|
var getter = property && property.get;
|
|
var getter = property && property.get;
|
|
|
var setter = property && property.set;
|
|
var setter = property && property.set;
|
|
|
|
|
|
|
|
- // if doNotObserve is true, only use the child value observer
|
|
|
|
|
- // if it already exists, and do not attempt to create it.
|
|
|
|
|
- // this allows freezing a large object from the root and
|
|
|
|
|
- // avoid unnecessary observation inside v-for fragments.
|
|
|
|
|
- var childOb = doNotObserve ? isObject(val) && val.__ob__ : observe(val);
|
|
|
|
|
|
|
+ var childOb = observe(val);
|
|
|
Object.defineProperty(obj, key, {
|
|
Object.defineProperty(obj, key, {
|
|
|
enumerable: true,
|
|
enumerable: true,
|
|
|
configurable: true,
|
|
configurable: true,
|
|
@@ -2243,7 +2256,7 @@ function defineReactive(obj, key, val, doNotObserve) {
|
|
|
} else {
|
|
} else {
|
|
|
val = newVal;
|
|
val = newVal;
|
|
|
}
|
|
}
|
|
|
- childOb = doNotObserve ? isObject(newVal) && newVal.__ob__ : observe(newVal);
|
|
|
|
|
|
|
+ childOb = observe(newVal);
|
|
|
dep.notify();
|
|
dep.notify();
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
@@ -4017,7 +4030,9 @@ var vFor = {
|
|
|
// update data for track-by, object repeat &
|
|
// update data for track-by, object repeat &
|
|
|
// primitive values.
|
|
// primitive values.
|
|
|
if (trackByKey || convertedFromObject || primitive) {
|
|
if (trackByKey || convertedFromObject || primitive) {
|
|
|
- frag.scope[alias] = value;
|
|
|
|
|
|
|
+ withoutConversion(function () {
|
|
|
|
|
+ frag.scope[alias] = value;
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
// new isntance
|
|
// new isntance
|
|
@@ -4107,7 +4122,11 @@ var vFor = {
|
|
|
// for two-way binding on alias
|
|
// for two-way binding on alias
|
|
|
scope.$forContext = this;
|
|
scope.$forContext = this;
|
|
|
// define scope properties
|
|
// define scope properties
|
|
|
- defineReactive(scope, alias, value, true /* do not observe */);
|
|
|
|
|
|
|
+ // important: define the scope alias without forced conversion
|
|
|
|
|
+ // so that frozen data structures remain non-reactive.
|
|
|
|
|
+ withoutConversion(function () {
|
|
|
|
|
+ defineReactive(scope, alias, value);
|
|
|
|
|
+ });
|
|
|
defineReactive(scope, '$index', index);
|
|
defineReactive(scope, '$index', index);
|
|
|
if (key) {
|
|
if (key) {
|
|
|
defineReactive(scope, '$key', key);
|
|
defineReactive(scope, '$key', key);
|
|
@@ -5705,7 +5724,9 @@ var component = {
|
|
|
|
|
|
|
|
unbuild: function unbuild(defer) {
|
|
unbuild: function unbuild(defer) {
|
|
|
if (this.waitingFor) {
|
|
if (this.waitingFor) {
|
|
|
- this.waitingFor.$destroy();
|
|
|
|
|
|
|
+ if (!this.keepAlive) {
|
|
|
|
|
+ this.waitingFor.$destroy();
|
|
|
|
|
+ }
|
|
|
this.waitingFor = null;
|
|
this.waitingFor = null;
|
|
|
}
|
|
}
|
|
|
var child = this.childVM;
|
|
var child = this.childVM;
|
|
@@ -5999,15 +6020,7 @@ function initProp(vm, prop, value) {
|
|
|
value = getPropDefaultValue(vm, prop.options);
|
|
value = getPropDefaultValue(vm, prop.options);
|
|
|
}
|
|
}
|
|
|
if (assertProp(prop, value)) {
|
|
if (assertProp(prop, value)) {
|
|
|
- var doNotObserve =
|
|
|
|
|
- // if the passed down prop was already converted, then
|
|
|
|
|
- // subsequent sets should also be converted, because the user
|
|
|
|
|
- // may mutate the prop binding in the child component (#2549)
|
|
|
|
|
- !(value && value.__ob__) && (
|
|
|
|
|
- // otherwise we can skip observation for props that are either
|
|
|
|
|
- // literal or points to a simple path (non-derived values)
|
|
|
|
|
- !prop.dynamic || isSimplePath(prop.raw));
|
|
|
|
|
- defineReactive(vm, key, value, doNotObserve);
|
|
|
|
|
|
|
+ defineReactive(vm, key, value);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -6126,11 +6139,18 @@ var propDef = {
|
|
|
var childKey = prop.path;
|
|
var childKey = prop.path;
|
|
|
var parentKey = prop.parentPath;
|
|
var parentKey = prop.parentPath;
|
|
|
var twoWay = prop.mode === bindingModes.TWO_WAY;
|
|
var twoWay = prop.mode === bindingModes.TWO_WAY;
|
|
|
|
|
+ var isSimple = isSimplePath(parentKey);
|
|
|
|
|
|
|
|
var parentWatcher = this.parentWatcher = new Watcher(parent, parentKey, function (val) {
|
|
var parentWatcher = this.parentWatcher = new Watcher(parent, parentKey, function (val) {
|
|
|
val = coerceProp(prop, val);
|
|
val = coerceProp(prop, val);
|
|
|
if (assertProp(prop, val)) {
|
|
if (assertProp(prop, val)) {
|
|
|
- child[childKey] = val;
|
|
|
|
|
|
|
+ if (isSimple) {
|
|
|
|
|
+ withoutConversion(function () {
|
|
|
|
|
+ child[childKey] = val;
|
|
|
|
|
+ });
|
|
|
|
|
+ } else {
|
|
|
|
|
+ child[childKey] = val;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}, {
|
|
}, {
|
|
|
twoWay: twoWay,
|
|
twoWay: twoWay,
|
|
@@ -6141,7 +6161,14 @@ var propDef = {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
// set the child initial value.
|
|
// set the child initial value.
|
|
|
- initProp(child, prop, parentWatcher.value);
|
|
|
|
|
|
|
+ var value = parentWatcher.value;
|
|
|
|
|
+ if (isSimple && value !== undefined) {
|
|
|
|
|
+ withoutConversion(function () {
|
|
|
|
|
+ initProp(child, prop, value);
|
|
|
|
|
+ });
|
|
|
|
|
+ } else {
|
|
|
|
|
+ initProp(child, prop, value);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
// setup two-way binding
|
|
// setup two-way binding
|
|
|
if (twoWay) {
|
|
if (twoWay) {
|
|
@@ -7146,15 +7173,17 @@ function checkTerminalDirectives(el, attrs, options) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- var attr, name, value, matched, dirName, arg, def, termDef;
|
|
|
|
|
|
|
+ var attr, name, value, modifiers, matched, dirName, rawName, arg, def, termDef;
|
|
|
for (var i = 0, j = attrs.length; i < j; i++) {
|
|
for (var i = 0, j = attrs.length; i < j; i++) {
|
|
|
attr = attrs[i];
|
|
attr = attrs[i];
|
|
|
- if (matched = attr.name.match(dirAttrRE)) {
|
|
|
|
|
|
|
+ modifiers = parseModifiers(attr.name);
|
|
|
|
|
+ name = attr.name.replace(modifierRE, '');
|
|
|
|
|
+ if (matched = name.match(dirAttrRE)) {
|
|
|
def = resolveAsset(options, 'directives', matched[1]);
|
|
def = resolveAsset(options, 'directives', matched[1]);
|
|
|
if (def && def.terminal) {
|
|
if (def && def.terminal) {
|
|
|
if (!termDef || (def.priority || DEFAULT_TERMINAL_PRIORITY) > termDef.priority) {
|
|
if (!termDef || (def.priority || DEFAULT_TERMINAL_PRIORITY) > termDef.priority) {
|
|
|
termDef = def;
|
|
termDef = def;
|
|
|
- name = attr.name;
|
|
|
|
|
|
|
+ rawName = attr.name;
|
|
|
value = attr.value;
|
|
value = attr.value;
|
|
|
dirName = matched[1];
|
|
dirName = matched[1];
|
|
|
arg = matched[2];
|
|
arg = matched[2];
|
|
@@ -7164,7 +7193,7 @@ function checkTerminalDirectives(el, attrs, options) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (termDef) {
|
|
if (termDef) {
|
|
|
- return makeTerminalNodeLinkFn(el, dirName, value, options, termDef, name, arg);
|
|
|
|
|
|
|
+ return makeTerminalNodeLinkFn(el, dirName, value, options, termDef, rawName, arg, modifiers);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -7182,28 +7211,24 @@ skip.terminal = true;
|
|
|
* @param {String} value
|
|
* @param {String} value
|
|
|
* @param {Object} options
|
|
* @param {Object} options
|
|
|
* @param {Object} def
|
|
* @param {Object} def
|
|
|
- * @param {String} [attrName]
|
|
|
|
|
|
|
+ * @param {String} [rawName]
|
|
|
* @param {String} [arg]
|
|
* @param {String} [arg]
|
|
|
|
|
+ * @param {Object} [modifiers]
|
|
|
* @return {Function} terminalLinkFn
|
|
* @return {Function} terminalLinkFn
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
-function makeTerminalNodeLinkFn(el, dirName, value, options, def, attrName, arg) {
|
|
|
|
|
|
|
+function makeTerminalNodeLinkFn(el, dirName, value, options, def, rawName, arg, modifiers) {
|
|
|
var parsed = parseDirective(value);
|
|
var parsed = parseDirective(value);
|
|
|
var descriptor = {
|
|
var descriptor = {
|
|
|
name: dirName,
|
|
name: dirName,
|
|
|
|
|
+ arg: arg,
|
|
|
expression: parsed.expression,
|
|
expression: parsed.expression,
|
|
|
filters: parsed.filters,
|
|
filters: parsed.filters,
|
|
|
raw: value,
|
|
raw: value,
|
|
|
- rawName: attrName,
|
|
|
|
|
|
|
+ attr: rawName,
|
|
|
|
|
+ modifiers: modifiers,
|
|
|
def: def
|
|
def: def
|
|
|
};
|
|
};
|
|
|
- if (attrName) {
|
|
|
|
|
- descriptor.rawName = attrName;
|
|
|
|
|
- descriptor.modifiers = parseModifiers(attrName);
|
|
|
|
|
- }
|
|
|
|
|
- if (arg) {
|
|
|
|
|
- descriptor.arg = arg.replace(modifierRE, '');
|
|
|
|
|
- }
|
|
|
|
|
// check ref for v-for and router-view
|
|
// check ref for v-for and router-view
|
|
|
if (dirName === 'for' || dirName === 'router-view') {
|
|
if (dirName === 'for' || dirName === 'router-view') {
|
|
|
descriptor.ref = findRef(el);
|
|
descriptor.ref = findRef(el);
|
|
@@ -8133,7 +8158,7 @@ Directive.prototype._setupParams = function () {
|
|
|
var i = params.length;
|
|
var i = params.length;
|
|
|
var key, val, mappedKey;
|
|
var key, val, mappedKey;
|
|
|
while (i--) {
|
|
while (i--) {
|
|
|
- key = params[i];
|
|
|
|
|
|
|
+ key = hyphenate(params[i]);
|
|
|
mappedKey = camelize(key);
|
|
mappedKey = camelize(key);
|
|
|
val = getBindAttr(this.el, key);
|
|
val = getBindAttr(this.el, key);
|
|
|
if (val != null) {
|
|
if (val != null) {
|
|
@@ -9781,7 +9806,7 @@ function installGlobalAPI (Vue) {
|
|
|
|
|
|
|
|
installGlobalAPI(Vue);
|
|
installGlobalAPI(Vue);
|
|
|
|
|
|
|
|
-Vue.version = '1.0.19';
|
|
|
|
|
|
|
+Vue.version = '1.0.20';
|
|
|
|
|
|
|
|
// devtools global hook
|
|
// devtools global hook
|
|
|
/* istanbul ignore next */
|
|
/* istanbul ignore next */
|