guy 7 years ago
parent
commit
a2e8bbf767
  1. 177
      dist/fix/fix.js

177
dist/fix/fix.js vendored

@ -469,56 +469,53 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
function defineReactive(obj, observer, shallow) { function defineReactive(obj, observer, shallow) {
var props = {}; var props = {};
var model = void 0; var model = void 0;
if (typeof Proxy === 'function') { // if (typeof Proxy === 'function') {
var deps = {}, // const deps = {}, childObs = {}, cache = {}
childObs = {}, // _.each(obj, function (val, key) {
cache = {}; // if (key in $$skipArray) {
_.each(obj, function (val, key) { // return
if (key in $$skipArray) { // }
return; // cache[key] = val
} // const dep = deps[key] = (observer && observer['__dep' + key]) || new Dep()
cache[key] = val; // observer && (observer['__dep' + key] = dep)
var dep = deps[key] = observer && observer['__dep' + key] || new Dep(); // childObs[key] = !shallow && observe(val, observer, key)
observer && (observer['__dep' + key] = dep); // })
childObs[key] = !shallow && observe(val, observer, key); // return model = new Proxy(props, {
}); // has: function (target, key) {
return model = new Proxy(props, { // return key in obj;
has: function has(target, key) { // },
return key in obj; // get: function (target, key) {
}, // if (key in $$skipArray) {
get: function get(target, key) { // return target[key]
if (key in $$skipArray) { // }
return target[key]; // const value = cache[key]
} // if (Dep.target) {
var value = cache[key]; // deps[key].depend()
if (Dep.target) { // if (childObs[key]) {
deps[key].depend(); // childObs[key].dep.depend()
if (childObs[key]) { // if (_.isArray(value)) {
childObs[key].dep.depend(); // dependArray(value)
if (_.isArray(value)) { // }
dependArray(value); // }
} // }
} // return value
} // },
return value; // set: function (target, key, newVal) {
}, // if (key in $$skipArray) {
set: function set(target, key, newVal) { // return target[key] = newVal
if (key in $$skipArray) { // }
return target[key] = newVal; // const value = cache[key], dep = deps[key]
} // if (newVal === value || (newVal !== newVal && value !== value)) {
var value = cache[key], // return newVal
dep = deps[key]; // }
if (newVal === value || newVal !== newVal && value !== value) { // cache[key] = newVal
return newVal; // childObs[key] = !shallow && observe(newVal, observer, key)
} // obj[key] = childObs[key] ? childObs[key].model : newVal
cache[key] = newVal; // notify(model, key, dep)
childObs[key] = !shallow && observe(newVal, observer, key); // return obj[key]
obj[key] = childObs[key] ? childObs[key].model : newVal; // }
notify(model, key, dep); // })
return obj[key]; // }
}
});
}
_.each(obj, function (val, key) { _.each(obj, function (val, key) {
if (key in $$skipArray) { if (key in $$skipArray) {
return; return;
@ -893,16 +890,16 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
function defineComputed(vm, computed) { function defineComputed(vm, computed) {
var props = {}; var props = {};
if (typeof Proxy === 'function') { // if (typeof Proxy === 'function') {
return vm.$$computed = new Proxy(props, { // return vm.$$computed = new Proxy(props, {
has: function has(target, key) { // has: function (target, key) {
return computed && key in computed; // return computed && key in computed
}, // },
get: function get(target, key) { // get: function (target, key) {
return createComputedGetter(vm, key)(); // return createComputedGetter(vm, key)()
} // }
}); // })
} // }
var shouldCache = true; var shouldCache = true;
for (var key in computed) { for (var key in computed) {
if (!(key in vm)) { if (!(key in vm)) {
@ -968,36 +965,36 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
function defineProps(vm, keys) { function defineProps(vm, keys) {
var props = {}; var props = {};
if (typeof Proxy === 'function') { // if (typeof Proxy === 'function') {
return vm.model = new Proxy(props, { // return vm.model = new Proxy(props, {
has: function has(target, key) { // has: function (target, key) {
return keys.indexOf(key) > -1; // return keys.indexOf(key) > -1;
}, // },
get: function get(target, key) { // get: function (target, key) {
if (key in $$skipArray) { // if (key in $$skipArray) {
return props[key]; // return props[key]
} // }
if (vm.$$computed && key in vm.$$computed) { // if (vm.$$computed && key in vm.$$computed) {
return vm.$$computed[key]; // return vm.$$computed[key]
} // }
if (vm.$$state && key in vm.$$state) { // if (vm.$$state && key in vm.$$state) {
return vm.$$state[key]; // return vm.$$state[key]
} // }
return vm.$$model[key]; // return vm.$$model[key]
}, // },
set: function set(target, key, val) { // set: function (target, key, val) {
if (key in $$skipArray) { // if (key in $$skipArray) {
return props[key] = val; // return props[key] = val
} // }
if (vm.$$state && key in vm.$$state) { // if (vm.$$state && key in vm.$$state) {
return vm.$$state[key] = val; // return vm.$$state[key] = val
} // }
if (vm.$$model && key in vm.$$model) { // if (vm.$$model && key in vm.$$model) {
return vm.$$model[key] = val; // return vm.$$model[key] = val
} // }
} // }
}); // })
} // }
var _loop = function _loop(i, len) { var _loop = function _loop(i, len) {
var key = keys[i]; var key = keys[i];

Loading…
Cancel
Save