Skip to content

Commit 678ccdd

Browse files
committed
feat: Run setter logic for nested setters even if value didn't change
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.
1 parent d123c7e commit 678ccdd

19 files changed

+14215
-568
lines changed

dist/vue.common.dev.js

+67-65
Large diffs are not rendered by default.

dist/vue.common.prod.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/vue.esm.browser.js

+66-64
Original file line numberDiff line numberDiff line change
@@ -973,7 +973,7 @@ class Observer {
973973
walk (obj) {
974974
const keys = Object.keys(obj);
975975
for (let i = 0; i < keys.length; i++) {
976-
defineReactive$$1(obj, keys[i]);
976+
defineReactive(obj, keys[i]);
977977
}
978978
}
979979

@@ -1041,7 +1041,7 @@ function observe (value, asRootData) {
10411041
/**
10421042
* Define a reactive property on an Object.
10431043
*/
1044-
function defineReactive$$1 (
1044+
function defineReactive (
10451045
obj,
10461046
key,
10471047
val,
@@ -1082,7 +1082,9 @@ function defineReactive$$1 (
10821082
set: function reactiveSetter (newVal) {
10831083
const value = getter ? getter.call(obj) : val;
10841084
/* eslint-disable no-self-compare */
1085-
if (newVal === value || (newVal !== newVal && value !== value)) {
1085+
// We allow same values for getters
1086+
// See this: https://github.com/vuejs/vue/pull/7828#issuecomment-446820288
1087+
if ((newVal === value && !getter) || (newVal !== newVal && value !== value)) {
10861088
return
10871089
}
10881090
/* eslint-enable no-self-compare */
@@ -1133,7 +1135,7 @@ function set (target, key, val) {
11331135
target[key] = val;
11341136
return val
11351137
}
1136-
defineReactive$$1(ob.value, key, val);
1138+
defineReactive(ob.value, key, val);
11371139
ob.dep.notify();
11381140
return val
11391141
}
@@ -1526,9 +1528,9 @@ function normalizeDirectives (options) {
15261528
const dirs = options.directives;
15271529
if (dirs) {
15281530
for (const key in dirs) {
1529-
const def$$1 = dirs[key];
1530-
if (typeof def$$1 === 'function') {
1531-
dirs[key] = { bind: def$$1, update: def$$1 };
1531+
const def = dirs[key];
1532+
if (typeof def === 'function') {
1533+
dirs[key] = { bind: def, update: def };
15321534
}
15331535
}
15341536
}
@@ -2187,13 +2189,13 @@ function _traverse (val, seen) {
21872189
const normalizeEvent = cached((name) => {
21882190
const passive = name.charAt(0) === '&';
21892191
name = passive ? name.slice(1) : name;
2190-
const once$$1 = name.charAt(0) === '~'; // Prefixed last, checked first
2191-
name = once$$1 ? name.slice(1) : name;
2192+
const once = name.charAt(0) === '~'; // Prefixed last, checked first
2193+
name = once ? name.slice(1) : name;
21922194
const capture = name.charAt(0) === '!';
21932195
name = capture ? name.slice(1) : name;
21942196
return {
21952197
name,
2196-
once: once$$1,
2198+
once,
21972199
capture,
21982200
passive
21992201
}
@@ -2220,13 +2222,13 @@ function updateListeners (
22202222
on,
22212223
oldOn,
22222224
add,
2223-
remove$$1,
2225+
remove,
22242226
createOnceHandler,
22252227
vm
22262228
) {
2227-
let name, def$$1, cur, old, event;
2229+
let name, def, cur, old, event;
22282230
for (name in on) {
2229-
def$$1 = cur = on[name];
2231+
def = cur = on[name];
22302232
old = oldOn[name];
22312233
event = normalizeEvent(name);
22322234
if (isUndef(cur)) {
@@ -2250,7 +2252,7 @@ function updateListeners (
22502252
for (name in oldOn) {
22512253
if (isUndef(on[name])) {
22522254
event = normalizeEvent(name);
2253-
remove$$1(event.name, oldOn[name], event.capture);
2255+
remove(event.name, oldOn[name], event.capture);
22542256
}
22552257
}
22562258
}
@@ -2462,7 +2464,7 @@ function initInjections (vm) {
24622464
Object.keys(result).forEach(key => {
24632465
/* istanbul ignore else */
24642466
{
2465-
defineReactive$$1(vm, key, result[key], () => {
2467+
defineReactive(vm, key, result[key], () => {
24662468
warn(
24672469
`Avoid mutating an injected value directly since the changes will be ` +
24682470
`overwritten whenever the provided component re-renders. ` +
@@ -3511,10 +3513,10 @@ function initRender (vm) {
35113513

35123514
/* istanbul ignore else */
35133515
{
3514-
defineReactive$$1(vm, '$attrs', parentData && parentData.attrs || emptyObject, () => {
3516+
defineReactive(vm, '$attrs', parentData && parentData.attrs || emptyObject, () => {
35153517
!isUpdatingChildComponent && warn(`$attrs is readonly.`, vm);
35163518
}, true);
3517-
defineReactive$$1(vm, '$listeners', options._parentListeners || emptyObject, () => {
3519+
defineReactive(vm, '$listeners', options._parentListeners || emptyObject, () => {
35183520
!isUpdatingChildComponent && warn(`$listeners is readonly.`, vm);
35193521
}, true);
35203522
}
@@ -4391,7 +4393,7 @@ function queueWatcher (watcher) {
43914393

43924394

43934395

4394-
let uid$2 = 0;
4396+
let uid$1 = 0;
43954397

43964398
/**
43974399
* A watcher parses an expression, collects dependencies,
@@ -4440,7 +4442,7 @@ class Watcher {
44404442
this.deep = this.user = this.lazy = this.sync = false;
44414443
}
44424444
this.cb = cb;
4443-
this.id = ++uid$2; // uid for batching
4445+
this.id = ++uid$1; // uid for batching
44444446
this.active = true;
44454447
this.dirty = this.lazy; // for lazy watchers
44464448
this.deps = [];
@@ -4674,7 +4676,7 @@ function initProps (vm, propsOptions) {
46744676
vm
46754677
);
46764678
}
4677-
defineReactive$$1(props, key, value, () => {
4679+
defineReactive(props, key, value, () => {
46784680
if (!isRoot && !isUpdatingChildComponent) {
46794681
warn(
46804682
`Avoid mutating a prop directly since the value will be ` +
@@ -4955,13 +4957,13 @@ function stateMixin (Vue) {
49554957

49564958
/* */
49574959

4958-
let uid$3 = 0;
4960+
let uid$2 = 0;
49594961

49604962
function initMixin (Vue) {
49614963
Vue.prototype._init = function (options) {
49624964
const vm = this;
49634965
// a uid
4964-
vm._uid = uid$3++;
4966+
vm._uid = uid$2++;
49654967

49664968
let startTag, endTag;
49674969
/* istanbul ignore if */
@@ -5278,9 +5280,9 @@ function pruneCacheEntry (
52785280
keys,
52795281
current
52805282
) {
5281-
const cached$$1 = cache[key];
5282-
if (cached$$1 && (!current || cached$$1.tag !== current.tag)) {
5283-
cached$$1.componentInstance.$destroy();
5283+
const cached = cache[key];
5284+
if (cached && (!current || cached.tag !== current.tag)) {
5285+
cached.componentInstance.$destroy();
52845286
}
52855287
cache[key] = null;
52865288
remove(keys, key);
@@ -5387,7 +5389,7 @@ function initGlobalAPI (Vue) {
53875389
warn,
53885390
extend,
53895391
mergeOptions,
5390-
defineReactive: defineReactive$$1
5392+
defineReactive
53915393
};
53925394

53935395
Vue.set = set;
@@ -5854,13 +5856,13 @@ function createPatchFunction (backend) {
58545856
}
58555857

58565858
function createRmCb (childElm, listeners) {
5857-
function remove$$1 () {
5858-
if (--remove$$1.listeners === 0) {
5859+
function remove () {
5860+
if (--remove.listeners === 0) {
58595861
removeNode(childElm);
58605862
}
58615863
}
5862-
remove$$1.listeners = listeners;
5863-
return remove$$1
5864+
remove.listeners = listeners;
5865+
return remove
58645866
}
58655867

58665868
function removeNode (el) {
@@ -5871,7 +5873,7 @@ function createPatchFunction (backend) {
58715873
}
58725874
}
58735875

5874-
function isUnknownElement$$1 (vnode, inVPre) {
5876+
function isUnknownElement (vnode, inVPre) {
58755877
return (
58765878
!inVPre &&
58775879
!vnode.ns &&
@@ -5920,7 +5922,7 @@ function createPatchFunction (backend) {
59205922
if (data && data.pre) {
59215923
creatingElmInVPre++;
59225924
}
5923-
if (isUnknownElement$$1(vnode, creatingElmInVPre)) {
5925+
if (isUnknownElement(vnode, creatingElmInVPre)) {
59245926
warn(
59255927
'Unknown custom element: <' + tag + '> - did you ' +
59265928
'register the component correctly? For recursive components, ' +
@@ -6018,11 +6020,11 @@ function createPatchFunction (backend) {
60186020
insert(parentElm, vnode.elm, refElm);
60196021
}
60206022

6021-
function insert (parent, elm, ref$$1) {
6023+
function insert (parent, elm, ref) {
60226024
if (isDef(parent)) {
6023-
if (isDef(ref$$1)) {
6024-
if (nodeOps.parentNode(ref$$1) === parent) {
6025-
nodeOps.insertBefore(parent, elm, ref$$1);
6025+
if (isDef(ref)) {
6026+
if (nodeOps.parentNode(ref) === parent) {
6027+
nodeOps.insertBefore(parent, elm, ref);
60266028
}
60276029
} else {
60286030
nodeOps.appendChild(parent, elm);
@@ -6436,7 +6438,7 @@ function createPatchFunction (backend) {
64366438
function assertNodeMatch (node, vnode, inVPre) {
64376439
if (isDef(vnode.tag)) {
64386440
return vnode.tag.indexOf('vue-component') === 0 || (
6439-
!isUnknownElement$$1(vnode, inVPre) &&
6441+
!isUnknownElement(vnode, inVPre) &&
64406442
vnode.tag.toLowerCase() === (node.tagName && node.tagName.toLowerCase())
64416443
)
64426444
} else {
@@ -7909,20 +7911,20 @@ function removeClass (el, cls) {
79097911

79107912
/* */
79117913

7912-
function resolveTransition (def$$1) {
7913-
if (!def$$1) {
7914+
function resolveTransition (def) {
7915+
if (!def) {
79147916
return
79157917
}
79167918
/* istanbul ignore else */
7917-
if (typeof def$$1 === 'object') {
7919+
if (typeof def === 'object') {
79187920
const res = {};
7919-
if (def$$1.css !== false) {
7920-
extend(res, autoCssTransition(def$$1.name || 'v'));
7921+
if (def.css !== false) {
7922+
extend(res, autoCssTransition(def.name || 'v'));
79217923
}
7922-
extend(res, def$$1);
7924+
extend(res, def);
79237925
return res
7924-
} else if (typeof def$$1 === 'string') {
7925-
return autoCssTransition(def$$1)
7926+
} else if (typeof def === 'string') {
7927+
return autoCssTransition(def)
79267928
}
79277929
}
79287930

@@ -8583,10 +8585,10 @@ function locateNode (vnode) {
85838585
var show = {
85848586
bind (el, { value }, vnode) {
85858587
vnode = locateNode(vnode);
8586-
const transition$$1 = vnode.data && vnode.data.transition;
8588+
const transition = vnode.data && vnode.data.transition;
85878589
const originalDisplay = el.__vOriginalDisplay =
85888590
el.style.display === 'none' ? '' : el.style.display;
8589-
if (value && transition$$1) {
8591+
if (value && transition) {
85908592
vnode.data.show = true;
85918593
enter(vnode, () => {
85928594
el.style.display = originalDisplay;
@@ -8600,8 +8602,8 @@ var show = {
86008602
/* istanbul ignore if */
86018603
if (!value === !oldValue) return
86028604
vnode = locateNode(vnode);
8603-
const transition$$1 = vnode.data && vnode.data.transition;
8604-
if (transition$$1) {
8605+
const transition = vnode.data && vnode.data.transition;
8606+
if (transition) {
86058607
vnode.data.show = true;
86068608
if (value) {
86078609
enter(vnode, () => {
@@ -9261,8 +9263,8 @@ function decodeAttr (value, shouldDecodeNewlines) {
92619263
function parseHTML (html, options) {
92629264
const stack = [];
92639265
const expectHTML = options.expectHTML;
9264-
const isUnaryTag$$1 = options.isUnaryTag || no;
9265-
const canBeLeftOpenTag$$1 = options.canBeLeftOpenTag || no;
9266+
const isUnaryTag = options.isUnaryTag || no;
9267+
const canBeLeftOpenTag = options.canBeLeftOpenTag || no;
92669268
let index = 0;
92679269
let last, lastTag;
92689270
while (html) {
@@ -9424,12 +9426,12 @@ function parseHTML (html, options) {
94249426
if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
94259427
parseEndTag(lastTag);
94269428
}
9427-
if (canBeLeftOpenTag$$1(tagName) && lastTag === tagName) {
9429+
if (canBeLeftOpenTag(tagName) && lastTag === tagName) {
94289430
parseEndTag(tagName);
94299431
}
94309432
}
94319433

9432-
const unary = isUnaryTag$$1(tagName) || !!unarySlash;
9434+
const unary = isUnaryTag(tagName) || !!unarySlash;
94339435

94349436
const l = match.attrs.length;
94359437
const attrs = new Array(l);
@@ -10072,8 +10074,8 @@ function addIfCondition (el, condition) {
1007210074
}
1007310075

1007410076
function processOnce (el) {
10075-
const once$$1 = getAndRemoveAttr(el, 'v-once');
10076-
if (once$$1 != null) {
10077+
const once = getAndRemoveAttr(el, 'v-once');
10078+
if (once != null) {
1007710079
el.once = true;
1007810080
}
1007910081
}
@@ -11434,15 +11436,15 @@ function genSlot (el, state) {
1143411436
dynamic: attr.dynamic
1143511437
})))
1143611438
: null;
11437-
const bind$$1 = el.attrsMap['v-bind'];
11438-
if ((attrs || bind$$1) && !children) {
11439+
const bind = el.attrsMap['v-bind'];
11440+
if ((attrs || bind) && !children) {
1143911441
res += `,null`;
1144011442
}
1144111443
if (attrs) {
1144211444
res += `,${attrs}`;
1144311445
}
11444-
if (bind$$1) {
11445-
res += `${attrs ? '' : ',null'},${bind$$1}`;
11446+
if (bind) {
11447+
res += `${attrs ? '' : ',null'},${bind}`;
1144611448
}
1144711449
return res + ')'
1144811450
}
@@ -11671,7 +11673,7 @@ function createCompileToFunctionFn (compile) {
1167111673
vm
1167211674
) {
1167311675
options = extend({}, options);
11674-
const warn$$1 = options.warn || warn;
11676+
const warn$1 = options.warn || warn;
1167511677
delete options.warn;
1167611678

1167711679
/* istanbul ignore if */
@@ -11681,7 +11683,7 @@ function createCompileToFunctionFn (compile) {
1168111683
new Function('return 1');
1168211684
} catch (e) {
1168311685
if (e.toString().match(/unsafe-eval|CSP/)) {
11684-
warn$$1(
11686+
warn$1(
1168511687
'It seems you are using the standalone build of Vue.js in an ' +
1168611688
'environment with Content Security Policy that prohibits unsafe-eval. ' +
1168711689
'The template compiler cannot work in this environment. Consider ' +
@@ -11708,14 +11710,14 @@ function createCompileToFunctionFn (compile) {
1170811710
if (compiled.errors && compiled.errors.length) {
1170911711
if (options.outputSourceRange) {
1171011712
compiled.errors.forEach(e => {
11711-
warn$$1(
11713+
warn$1(
1171211714
`Error compiling template:\n\n${e.msg}\n\n` +
1171311715
generateCodeFrame(template, e.start, e.end),
1171411716
vm
1171511717
);
1171611718
});
1171711719
} else {
11718-
warn$$1(
11720+
warn$1(
1171911721
`Error compiling template:\n\n${template}\n\n` +
1172011722
compiled.errors.map(e => `- ${e}`).join('\n') + '\n',
1172111723
vm
@@ -11745,7 +11747,7 @@ function createCompileToFunctionFn (compile) {
1174511747
/* istanbul ignore if */
1174611748
{
1174711749
if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
11748-
warn$$1(
11750+
warn$1(
1174911751
`Failed to generate render function:\n\n` +
1175011752
fnGenErrors.map(({ err, code }) => `${err.toString()} in\n\n${code}\n`).join('\n'),
1175111753
vm

dist/vue.esm.browser.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)