Skip to content

Commit

Permalink
feat: Run setter logic for nested setters even if value didn't change
Browse files Browse the repository at this point in the history
Run setter logic for nested setters even if value didn't change. See this:
vuejs#7828 (comment).

BREAKING CHANGE: Run setter logic for nested setters even if value didn't change.
  • Loading branch information
jan-swiecki committed Mar 12, 2019
1 parent d123c7e commit 678ccdd
Show file tree
Hide file tree
Showing 19 changed files with 14,215 additions and 568 deletions.
132 changes: 67 additions & 65 deletions dist/vue.common.dev.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/vue.common.prod.js

Large diffs are not rendered by default.

130 changes: 66 additions & 64 deletions dist/vue.esm.browser.js
Expand Up @@ -973,7 +973,7 @@ class Observer {
walk (obj) {
const keys = Object.keys(obj);
for (let i = 0; i < keys.length; i++) {
defineReactive$$1(obj, keys[i]);
defineReactive(obj, keys[i]);
}
}

Expand Down Expand Up @@ -1041,7 +1041,7 @@ function observe (value, asRootData) {
/**
* Define a reactive property on an Object.
*/
function defineReactive$$1 (
function defineReactive (
obj,
key,
val,
Expand Down Expand Up @@ -1082,7 +1082,9 @@ function defineReactive$$1 (
set: function reactiveSetter (newVal) {
const value = getter ? getter.call(obj) : val;
/* eslint-disable no-self-compare */
if (newVal === value || (newVal !== newVal && value !== value)) {
// We allow same values for getters
// See this: https://github.com/vuejs/vue/pull/7828#issuecomment-446820288
if ((newVal === value && !getter) || (newVal !== newVal && value !== value)) {
return
}
/* eslint-enable no-self-compare */
Expand Down Expand Up @@ -1133,7 +1135,7 @@ function set (target, key, val) {
target[key] = val;
return val
}
defineReactive$$1(ob.value, key, val);
defineReactive(ob.value, key, val);
ob.dep.notify();
return val
}
Expand Down Expand Up @@ -1526,9 +1528,9 @@ function normalizeDirectives (options) {
const dirs = options.directives;
if (dirs) {
for (const key in dirs) {
const def$$1 = dirs[key];
if (typeof def$$1 === 'function') {
dirs[key] = { bind: def$$1, update: def$$1 };
const def = dirs[key];
if (typeof def === 'function') {
dirs[key] = { bind: def, update: def };
}
}
}
Expand Down Expand Up @@ -2187,13 +2189,13 @@ function _traverse (val, seen) {
const normalizeEvent = cached((name) => {
const passive = name.charAt(0) === '&';
name = passive ? name.slice(1) : name;
const once$$1 = name.charAt(0) === '~'; // Prefixed last, checked first
name = once$$1 ? name.slice(1) : name;
const once = name.charAt(0) === '~'; // Prefixed last, checked first
name = once ? name.slice(1) : name;
const capture = name.charAt(0) === '!';
name = capture ? name.slice(1) : name;
return {
name,
once: once$$1,
once,
capture,
passive
}
Expand All @@ -2220,13 +2222,13 @@ function updateListeners (
on,
oldOn,
add,
remove$$1,
remove,
createOnceHandler,
vm
) {
let name, def$$1, cur, old, event;
let name, def, cur, old, event;
for (name in on) {
def$$1 = cur = on[name];
def = cur = on[name];
old = oldOn[name];
event = normalizeEvent(name);
if (isUndef(cur)) {
Expand All @@ -2250,7 +2252,7 @@ function updateListeners (
for (name in oldOn) {
if (isUndef(on[name])) {
event = normalizeEvent(name);
remove$$1(event.name, oldOn[name], event.capture);
remove(event.name, oldOn[name], event.capture);
}
}
}
Expand Down Expand Up @@ -2462,7 +2464,7 @@ function initInjections (vm) {
Object.keys(result).forEach(key => {
/* istanbul ignore else */
{
defineReactive$$1(vm, key, result[key], () => {
defineReactive(vm, key, result[key], () => {
warn(
`Avoid mutating an injected value directly since the changes will be ` +
`overwritten whenever the provided component re-renders. ` +
Expand Down Expand Up @@ -3511,10 +3513,10 @@ function initRender (vm) {

/* istanbul ignore else */
{
defineReactive$$1(vm, '$attrs', parentData && parentData.attrs || emptyObject, () => {
defineReactive(vm, '$attrs', parentData && parentData.attrs || emptyObject, () => {
!isUpdatingChildComponent && warn(`$attrs is readonly.`, vm);
}, true);
defineReactive$$1(vm, '$listeners', options._parentListeners || emptyObject, () => {
defineReactive(vm, '$listeners', options._parentListeners || emptyObject, () => {
!isUpdatingChildComponent && warn(`$listeners is readonly.`, vm);
}, true);
}
Expand Down Expand Up @@ -4391,7 +4393,7 @@ function queueWatcher (watcher) {



let uid$2 = 0;
let uid$1 = 0;

/**
* A watcher parses an expression, collects dependencies,
Expand Down Expand Up @@ -4440,7 +4442,7 @@ class Watcher {
this.deep = this.user = this.lazy = this.sync = false;
}
this.cb = cb;
this.id = ++uid$2; // uid for batching
this.id = ++uid$1; // uid for batching
this.active = true;
this.dirty = this.lazy; // for lazy watchers
this.deps = [];
Expand Down Expand Up @@ -4674,7 +4676,7 @@ function initProps (vm, propsOptions) {
vm
);
}
defineReactive$$1(props, key, value, () => {
defineReactive(props, key, value, () => {
if (!isRoot && !isUpdatingChildComponent) {
warn(
`Avoid mutating a prop directly since the value will be ` +
Expand Down Expand Up @@ -4955,13 +4957,13 @@ function stateMixin (Vue) {

/* */

let uid$3 = 0;
let uid$2 = 0;

function initMixin (Vue) {
Vue.prototype._init = function (options) {
const vm = this;
// a uid
vm._uid = uid$3++;
vm._uid = uid$2++;

let startTag, endTag;
/* istanbul ignore if */
Expand Down Expand Up @@ -5278,9 +5280,9 @@ function pruneCacheEntry (
keys,
current
) {
const cached$$1 = cache[key];
if (cached$$1 && (!current || cached$$1.tag !== current.tag)) {
cached$$1.componentInstance.$destroy();
const cached = cache[key];
if (cached && (!current || cached.tag !== current.tag)) {
cached.componentInstance.$destroy();
}
cache[key] = null;
remove(keys, key);
Expand Down Expand Up @@ -5387,7 +5389,7 @@ function initGlobalAPI (Vue) {
warn,
extend,
mergeOptions,
defineReactive: defineReactive$$1
defineReactive
};

Vue.set = set;
Expand Down Expand Up @@ -5854,13 +5856,13 @@ function createPatchFunction (backend) {
}

function createRmCb (childElm, listeners) {
function remove$$1 () {
if (--remove$$1.listeners === 0) {
function remove () {
if (--remove.listeners === 0) {
removeNode(childElm);
}
}
remove$$1.listeners = listeners;
return remove$$1
remove.listeners = listeners;
return remove
}

function removeNode (el) {
Expand All @@ -5871,7 +5873,7 @@ function createPatchFunction (backend) {
}
}

function isUnknownElement$$1 (vnode, inVPre) {
function isUnknownElement (vnode, inVPre) {
return (
!inVPre &&
!vnode.ns &&
Expand Down Expand Up @@ -5920,7 +5922,7 @@ function createPatchFunction (backend) {
if (data && data.pre) {
creatingElmInVPre++;
}
if (isUnknownElement$$1(vnode, creatingElmInVPre)) {
if (isUnknownElement(vnode, creatingElmInVPre)) {
warn(
'Unknown custom element: <' + tag + '> - did you ' +
'register the component correctly? For recursive components, ' +
Expand Down Expand Up @@ -6018,11 +6020,11 @@ function createPatchFunction (backend) {
insert(parentElm, vnode.elm, refElm);
}

function insert (parent, elm, ref$$1) {
function insert (parent, elm, ref) {
if (isDef(parent)) {
if (isDef(ref$$1)) {
if (nodeOps.parentNode(ref$$1) === parent) {
nodeOps.insertBefore(parent, elm, ref$$1);
if (isDef(ref)) {
if (nodeOps.parentNode(ref) === parent) {
nodeOps.insertBefore(parent, elm, ref);
}
} else {
nodeOps.appendChild(parent, elm);
Expand Down Expand Up @@ -6436,7 +6438,7 @@ function createPatchFunction (backend) {
function assertNodeMatch (node, vnode, inVPre) {
if (isDef(vnode.tag)) {
return vnode.tag.indexOf('vue-component') === 0 || (
!isUnknownElement$$1(vnode, inVPre) &&
!isUnknownElement(vnode, inVPre) &&
vnode.tag.toLowerCase() === (node.tagName && node.tagName.toLowerCase())
)
} else {
Expand Down Expand Up @@ -7909,20 +7911,20 @@ function removeClass (el, cls) {

/* */

function resolveTransition (def$$1) {
if (!def$$1) {
function resolveTransition (def) {
if (!def) {
return
}
/* istanbul ignore else */
if (typeof def$$1 === 'object') {
if (typeof def === 'object') {
const res = {};
if (def$$1.css !== false) {
extend(res, autoCssTransition(def$$1.name || 'v'));
if (def.css !== false) {
extend(res, autoCssTransition(def.name || 'v'));
}
extend(res, def$$1);
extend(res, def);
return res
} else if (typeof def$$1 === 'string') {
return autoCssTransition(def$$1)
} else if (typeof def === 'string') {
return autoCssTransition(def)
}
}

Expand Down Expand Up @@ -8583,10 +8585,10 @@ function locateNode (vnode) {
var show = {
bind (el, { value }, vnode) {
vnode = locateNode(vnode);
const transition$$1 = vnode.data && vnode.data.transition;
const transition = vnode.data && vnode.data.transition;
const originalDisplay = el.__vOriginalDisplay =
el.style.display === 'none' ? '' : el.style.display;
if (value && transition$$1) {
if (value && transition) {
vnode.data.show = true;
enter(vnode, () => {
el.style.display = originalDisplay;
Expand All @@ -8600,8 +8602,8 @@ var show = {
/* istanbul ignore if */
if (!value === !oldValue) return
vnode = locateNode(vnode);
const transition$$1 = vnode.data && vnode.data.transition;
if (transition$$1) {
const transition = vnode.data && vnode.data.transition;
if (transition) {
vnode.data.show = true;
if (value) {
enter(vnode, () => {
Expand Down Expand Up @@ -9261,8 +9263,8 @@ function decodeAttr (value, shouldDecodeNewlines) {
function parseHTML (html, options) {
const stack = [];
const expectHTML = options.expectHTML;
const isUnaryTag$$1 = options.isUnaryTag || no;
const canBeLeftOpenTag$$1 = options.canBeLeftOpenTag || no;
const isUnaryTag = options.isUnaryTag || no;
const canBeLeftOpenTag = options.canBeLeftOpenTag || no;
let index = 0;
let last, lastTag;
while (html) {
Expand Down Expand Up @@ -9424,12 +9426,12 @@ function parseHTML (html, options) {
if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
parseEndTag(lastTag);
}
if (canBeLeftOpenTag$$1(tagName) && lastTag === tagName) {
if (canBeLeftOpenTag(tagName) && lastTag === tagName) {
parseEndTag(tagName);
}
}

const unary = isUnaryTag$$1(tagName) || !!unarySlash;
const unary = isUnaryTag(tagName) || !!unarySlash;

const l = match.attrs.length;
const attrs = new Array(l);
Expand Down Expand Up @@ -10072,8 +10074,8 @@ function addIfCondition (el, condition) {
}

function processOnce (el) {
const once$$1 = getAndRemoveAttr(el, 'v-once');
if (once$$1 != null) {
const once = getAndRemoveAttr(el, 'v-once');
if (once != null) {
el.once = true;
}
}
Expand Down Expand Up @@ -11434,15 +11436,15 @@ function genSlot (el, state) {
dynamic: attr.dynamic
})))
: null;
const bind$$1 = el.attrsMap['v-bind'];
if ((attrs || bind$$1) && !children) {
const bind = el.attrsMap['v-bind'];
if ((attrs || bind) && !children) {
res += `,null`;
}
if (attrs) {
res += `,${attrs}`;
}
if (bind$$1) {
res += `${attrs ? '' : ',null'},${bind$$1}`;
if (bind) {
res += `${attrs ? '' : ',null'},${bind}`;
}
return res + ')'
}
Expand Down Expand Up @@ -11671,7 +11673,7 @@ function createCompileToFunctionFn (compile) {
vm
) {
options = extend({}, options);
const warn$$1 = options.warn || warn;
const warn$1 = options.warn || warn;
delete options.warn;

/* istanbul ignore if */
Expand All @@ -11681,7 +11683,7 @@ function createCompileToFunctionFn (compile) {
new Function('return 1');
} catch (e) {
if (e.toString().match(/unsafe-eval|CSP/)) {
warn$$1(
warn$1(
'It seems you are using the standalone build of Vue.js in an ' +
'environment with Content Security Policy that prohibits unsafe-eval. ' +
'The template compiler cannot work in this environment. Consider ' +
Expand All @@ -11708,14 +11710,14 @@ function createCompileToFunctionFn (compile) {
if (compiled.errors && compiled.errors.length) {
if (options.outputSourceRange) {
compiled.errors.forEach(e => {
warn$$1(
warn$1(
`Error compiling template:\n\n${e.msg}\n\n` +
generateCodeFrame(template, e.start, e.end),
vm
);
});
} else {
warn$$1(
warn$1(
`Error compiling template:\n\n${template}\n\n` +
compiled.errors.map(e => `- ${e}`).join('\n') + '\n',
vm
Expand Down Expand Up @@ -11745,7 +11747,7 @@ function createCompileToFunctionFn (compile) {
/* istanbul ignore if */
{
if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
warn$$1(
warn$1(
`Failed to generate render function:\n\n` +
fnGenErrors.map(({ err, code }) => `${err.toString()} in\n\n${code}\n`).join('\n'),
vm
Expand Down
2 changes: 1 addition & 1 deletion dist/vue.esm.browser.min.js

Large diffs are not rendered by default.

0 comments on commit 678ccdd

Please sign in to comment.