vue 2.6.6 → 2.6.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/README.md +24 -19
  2. package/dist/README.md +1 -1
  3. package/dist/vue.common.dev.js +169 -80
  4. package/dist/vue.common.prod.js +2 -2
  5. package/dist/vue.esm.browser.js +167 -76
  6. package/dist/vue.esm.browser.min.js +2 -2
  7. package/dist/vue.esm.js +169 -80
  8. package/dist/vue.js +169 -80
  9. package/dist/vue.min.js +2 -2
  10. package/dist/vue.runtime.common.dev.js +121 -62
  11. package/dist/vue.runtime.common.prod.js +2 -2
  12. package/dist/vue.runtime.esm.js +121 -62
  13. package/dist/vue.runtime.js +121 -62
  14. package/dist/vue.runtime.min.js +2 -2
  15. package/package.json +2 -2
  16. package/src/compiler/codeframe.js +7 -5
  17. package/src/compiler/codegen/events.js +1 -1
  18. package/src/compiler/codegen/index.js +38 -9
  19. package/src/compiler/parser/html-parser.js +3 -3
  20. package/src/compiler/parser/index.js +4 -3
  21. package/src/core/instance/lifecycle.js +5 -2
  22. package/src/core/instance/render-helpers/bind-object-props.js +5 -3
  23. package/src/core/instance/render-helpers/resolve-scoped-slots.js +7 -2
  24. package/src/core/observer/scheduler.js +17 -6
  25. package/src/core/util/error.js +24 -13
  26. package/src/core/util/lang.js +2 -2
  27. package/src/core/util/options.js +2 -2
  28. package/src/core/vdom/helpers/normalize-scoped-slots.js +14 -5
  29. package/src/core/vdom/helpers/resolve-async-component.js +25 -8
  30. package/src/platforms/web/runtime/modules/dom-props.js +15 -12
  31. package/src/platforms/web/runtime/modules/events.js +4 -2
  32. package/src/platforms/web/runtime/modules/transition.js +1 -1
  33. package/src/server/template-renderer/create-async-file-mapper.js +2 -2
  34. package/src/server/write.js +1 -1
  35. package/types/options.d.ts +3 -3
  36. package/types/vnode.d.ts +6 -2
  37. package/types/vue.d.ts +3 -3
package/dist/vue.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Vue.js v2.6.6
2
+ * Vue.js v2.6.10
3
3
  * (c) 2014-2019 Evan You
4
4
  * Released under the MIT License.
5
5
  */
@@ -475,7 +475,7 @@ var config = ({
475
475
  * using https://www.w3.org/TR/html53/semantics-scripting.html#potentialcustomelementname
476
476
  * skipping \u10000-\uEFFFF due to it freezing up PhantomJS
477
477
  */
478
- var unicodeLetters = 'a-zA-Z\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD';
478
+ var unicodeRegExp = /a-zA-Z\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD/;
479
479
 
480
480
  /**
481
481
  * Check if a string starts with $ or _
@@ -500,7 +500,7 @@ function def (obj, key, val, enumerable) {
500
500
  /**
501
501
  * Parse simple path.
502
502
  */
503
- var bailRE = new RegExp(("[^" + unicodeLetters + ".$_\\d]"));
503
+ var bailRE = new RegExp(("[^" + (unicodeRegExp.source) + ".$_\\d]"));
504
504
  function parsePath (path) {
505
505
  if (bailRE.test(path)) {
506
506
  return
@@ -1406,7 +1406,7 @@ function checkComponents (options) {
1406
1406
  }
1407
1407
 
1408
1408
  function validateComponentName (name) {
1409
- if (!new RegExp(("^[a-zA-Z][\\-\\.0-9_" + unicodeLetters + "]*$")).test(name)) {
1409
+ if (!new RegExp(("^[a-zA-Z][\\-\\.0-9_" + (unicodeRegExp.source) + "]*$")).test(name)) {
1410
1410
  warn(
1411
1411
  'Invalid component name: "' + name + '". Component names ' +
1412
1412
  'should conform to valid custom element name in html5 specification.'
@@ -1825,23 +1825,30 @@ function isBoolean () {
1825
1825
  /* */
1826
1826
 
1827
1827
  function handleError (err, vm, info) {
1828
- if (vm) {
1829
- var cur = vm;
1830
- while ((cur = cur.$parent)) {
1831
- var hooks = cur.$options.errorCaptured;
1832
- if (hooks) {
1833
- for (var i = 0; i < hooks.length; i++) {
1834
- try {
1835
- var capture = hooks[i].call(cur, err, vm, info) === false;
1836
- if (capture) { return }
1837
- } catch (e) {
1838
- globalHandleError(e, cur, 'errorCaptured hook');
1828
+ // Deactivate deps tracking while processing error handler to avoid possible infinite rendering.
1829
+ // See: https://github.com/vuejs/vuex/issues/1505
1830
+ pushTarget();
1831
+ try {
1832
+ if (vm) {
1833
+ var cur = vm;
1834
+ while ((cur = cur.$parent)) {
1835
+ var hooks = cur.$options.errorCaptured;
1836
+ if (hooks) {
1837
+ for (var i = 0; i < hooks.length; i++) {
1838
+ try {
1839
+ var capture = hooks[i].call(cur, err, vm, info) === false;
1840
+ if (capture) { return }
1841
+ } catch (e) {
1842
+ globalHandleError(e, cur, 'errorCaptured hook');
1843
+ }
1839
1844
  }
1840
1845
  }
1841
1846
  }
1842
1847
  }
1848
+ globalHandleError(err, vm, info);
1849
+ } finally {
1850
+ popTarget();
1843
1851
  }
1844
- globalHandleError(err, vm, info);
1845
1852
  }
1846
1853
 
1847
1854
  function invokeWithErrorHandling (
@@ -1854,8 +1861,11 @@ function invokeWithErrorHandling (
1854
1861
  var res;
1855
1862
  try {
1856
1863
  res = args ? handler.apply(context, args) : handler.call(context);
1857
- if (res && !res._isVue && isPromise(res)) {
1864
+ if (res && !res._isVue && isPromise(res) && !res._handled) {
1858
1865
  res.catch(function (e) { return handleError(e, vm, info + " (Promise/async)"); });
1866
+ // issue #9511
1867
+ // avoid catch triggering multiple times when nested calls
1868
+ res._handled = true;
1859
1869
  }
1860
1870
  } catch (e) {
1861
1871
  handleError(e, vm, info);
@@ -2540,32 +2550,37 @@ function normalizeScopedSlots (
2540
2550
  prevSlots
2541
2551
  ) {
2542
2552
  var res;
2553
+ var hasNormalSlots = Object.keys(normalSlots).length > 0;
2554
+ var isStable = slots ? !!slots.$stable : !hasNormalSlots;
2555
+ var key = slots && slots.$key;
2543
2556
  if (!slots) {
2544
2557
  res = {};
2545
2558
  } else if (slots._normalized) {
2546
2559
  // fast path 1: child component re-render only, parent did not change
2547
2560
  return slots._normalized
2548
2561
  } else if (
2549
- slots.$stable &&
2562
+ isStable &&
2550
2563
  prevSlots &&
2551
2564
  prevSlots !== emptyObject &&
2552
- Object.keys(normalSlots).length === 0
2565
+ key === prevSlots.$key &&
2566
+ !hasNormalSlots &&
2567
+ !prevSlots.$hasNormal
2553
2568
  ) {
2554
2569
  // fast path 2: stable scoped slots w/ no normal slots to proxy,
2555
2570
  // only need to normalize once
2556
2571
  return prevSlots
2557
2572
  } else {
2558
2573
  res = {};
2559
- for (var key in slots) {
2560
- if (slots[key] && key[0] !== '$') {
2561
- res[key] = normalizeScopedSlot(normalSlots, key, slots[key]);
2574
+ for (var key$1 in slots) {
2575
+ if (slots[key$1] && key$1[0] !== '$') {
2576
+ res[key$1] = normalizeScopedSlot(normalSlots, key$1, slots[key$1]);
2562
2577
  }
2563
2578
  }
2564
2579
  }
2565
2580
  // expose normal slots on scopedSlots
2566
- for (var key$1 in normalSlots) {
2567
- if (!(key$1 in res)) {
2568
- res[key$1] = proxyNormalSlot(normalSlots, key$1);
2581
+ for (var key$2 in normalSlots) {
2582
+ if (!(key$2 in res)) {
2583
+ res[key$2] = proxyNormalSlot(normalSlots, key$2);
2569
2584
  }
2570
2585
  }
2571
2586
  // avoriaz seems to mock a non-extensible $scopedSlots object
@@ -2573,7 +2588,9 @@ function normalizeScopedSlots (
2573
2588
  if (slots && Object.isExtensible(slots)) {
2574
2589
  (slots)._normalized = res;
2575
2590
  }
2576
- def(res, '$stable', slots ? !!slots.$stable : true);
2591
+ def(res, '$stable', isStable);
2592
+ def(res, '$key', key);
2593
+ def(res, '$hasNormal', hasNormalSlots);
2577
2594
  return res
2578
2595
  }
2579
2596
 
@@ -2583,8 +2600,10 @@ function normalizeScopedSlot(normalSlots, key, fn) {
2583
2600
  res = res && typeof res === 'object' && !Array.isArray(res)
2584
2601
  ? [res] // single vnode
2585
2602
  : normalizeChildren(res);
2586
- return res && res.length === 0
2587
- ? undefined
2603
+ return res && (
2604
+ res.length === 0 ||
2605
+ (res.length === 1 && res[0].isComment) // #9658
2606
+ ) ? undefined
2588
2607
  : res
2589
2608
  };
2590
2609
  // this is a slot using the new v-slot syntax without scope. although it is
@@ -2764,12 +2783,13 @@ function bindObjectProps (
2764
2783
  : data.attrs || (data.attrs = {});
2765
2784
  }
2766
2785
  var camelizedKey = camelize(key);
2767
- if (!(key in hash) && !(camelizedKey in hash)) {
2786
+ var hyphenatedKey = hyphenate(key);
2787
+ if (!(camelizedKey in hash) && !(hyphenatedKey in hash)) {
2768
2788
  hash[key] = value[key];
2769
2789
 
2770
2790
  if (isSync) {
2771
2791
  var on = data.on || (data.on = {});
2772
- on[("update:" + camelizedKey)] = function ($event) {
2792
+ on[("update:" + key)] = function ($event) {
2773
2793
  value[key] = $event;
2774
2794
  };
2775
2795
  }
@@ -2868,14 +2888,16 @@ function bindObjectListeners (data, value) {
2868
2888
 
2869
2889
  function resolveScopedSlots (
2870
2890
  fns, // see flow/vnode
2891
+ res,
2892
+ // the following are added in 2.6
2871
2893
  hasDynamicKeys,
2872
- res
2894
+ contentHashKey
2873
2895
  ) {
2874
2896
  res = res || { $stable: !hasDynamicKeys };
2875
2897
  for (var i = 0; i < fns.length; i++) {
2876
2898
  var slot = fns[i];
2877
2899
  if (Array.isArray(slot)) {
2878
- resolveScopedSlots(slot, hasDynamicKeys, res);
2900
+ resolveScopedSlots(slot, res, hasDynamicKeys);
2879
2901
  } else if (slot) {
2880
2902
  // marker for reverse proxying v-slot without scope on this.$slots
2881
2903
  if (slot.proxy) {
@@ -2884,6 +2906,9 @@ function resolveScopedSlots (
2884
2906
  res[slot.key] = slot.fn;
2885
2907
  }
2886
2908
  }
2909
+ if (contentHashKey) {
2910
+ (res).$key = contentHashKey;
2911
+ }
2887
2912
  return res
2888
2913
  }
2889
2914
 
@@ -3602,17 +3627,23 @@ function resolveAsyncComponent (
3602
3627
  return factory.resolved
3603
3628
  }
3604
3629
 
3630
+ var owner = currentRenderingInstance;
3631
+ if (owner && isDef(factory.owners) && factory.owners.indexOf(owner) === -1) {
3632
+ // already pending
3633
+ factory.owners.push(owner);
3634
+ }
3635
+
3605
3636
  if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
3606
3637
  return factory.loadingComp
3607
3638
  }
3608
3639
 
3609
- var owner = currentRenderingInstance;
3610
- if (isDef(factory.owners)) {
3611
- // already pending
3612
- factory.owners.push(owner);
3613
- } else {
3640
+ if (owner && !isDef(factory.owners)) {
3614
3641
  var owners = factory.owners = [owner];
3615
3642
  var sync = true;
3643
+ var timerLoading = null;
3644
+ var timerTimeout = null
3645
+
3646
+ ;(owner).$on('hook:destroyed', function () { return remove(owners, owner); });
3616
3647
 
3617
3648
  var forceRender = function (renderCompleted) {
3618
3649
  for (var i = 0, l = owners.length; i < l; i++) {
@@ -3621,6 +3652,14 @@ function resolveAsyncComponent (
3621
3652
 
3622
3653
  if (renderCompleted) {
3623
3654
  owners.length = 0;
3655
+ if (timerLoading !== null) {
3656
+ clearTimeout(timerLoading);
3657
+ timerLoading = null;
3658
+ }
3659
+ if (timerTimeout !== null) {
3660
+ clearTimeout(timerTimeout);
3661
+ timerTimeout = null;
3662
+ }
3624
3663
  }
3625
3664
  };
3626
3665
 
@@ -3667,7 +3706,8 @@ function resolveAsyncComponent (
3667
3706
  if (res.delay === 0) {
3668
3707
  factory.loading = true;
3669
3708
  } else {
3670
- setTimeout(function () {
3709
+ timerLoading = setTimeout(function () {
3710
+ timerLoading = null;
3671
3711
  if (isUndef(factory.resolved) && isUndef(factory.error)) {
3672
3712
  factory.loading = true;
3673
3713
  forceRender(false);
@@ -3677,7 +3717,8 @@ function resolveAsyncComponent (
3677
3717
  }
3678
3718
 
3679
3719
  if (isDef(res.timeout)) {
3680
- setTimeout(function () {
3720
+ timerTimeout = setTimeout(function () {
3721
+ timerTimeout = null;
3681
3722
  if (isUndef(factory.resolved)) {
3682
3723
  reject(
3683
3724
  process.env.NODE_ENV !== 'production'
@@ -4067,9 +4108,12 @@ function updateChildComponent (
4067
4108
  // check if there are dynamic scopedSlots (hand-written or compiled but with
4068
4109
  // dynamic slot names). Static scoped slots compiled from template has the
4069
4110
  // "$stable" marker.
4111
+ var newScopedSlots = parentVnode.data.scopedSlots;
4112
+ var oldScopedSlots = vm.$scopedSlots;
4070
4113
  var hasDynamicScopedSlot = !!(
4071
- (parentVnode.data.scopedSlots && !parentVnode.data.scopedSlots.$stable) ||
4072
- (vm.$scopedSlots !== emptyObject && !vm.$scopedSlots.$stable)
4114
+ (newScopedSlots && !newScopedSlots.$stable) ||
4115
+ (oldScopedSlots !== emptyObject && !oldScopedSlots.$stable) ||
4116
+ (newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key)
4073
4117
  );
4074
4118
 
4075
4119
  // Any static slot children from the parent may have changed during parent's
@@ -4222,11 +4266,21 @@ var getNow = Date.now;
4222
4266
  // timestamp can either be hi-res (relative to page load) or low-res
4223
4267
  // (relative to UNIX epoch), so in order to compare time we have to use the
4224
4268
  // same timestamp type when saving the flush timestamp.
4225
- if (inBrowser && getNow() > document.createEvent('Event').timeStamp) {
4226
- // if the low-res timestamp which is bigger than the event timestamp
4227
- // (which is evaluated AFTER) it means the event is using a hi-res timestamp,
4228
- // and we need to use the hi-res version for event listeners as well.
4229
- getNow = function () { return performance.now(); };
4269
+ // All IE versions use low-res event timestamps, and have problematic clock
4270
+ // implementations (#9632)
4271
+ if (inBrowser && !isIE) {
4272
+ var performance = window.performance;
4273
+ if (
4274
+ performance &&
4275
+ typeof performance.now === 'function' &&
4276
+ getNow() > document.createEvent('Event').timeStamp
4277
+ ) {
4278
+ // if the event timestamp, although evaluated AFTER the Date.now(), is
4279
+ // smaller than it, it means the event is using a hi-res timestamp,
4280
+ // and we need to use the hi-res version for event listener timestamps as
4281
+ // well.
4282
+ getNow = function () { return performance.now(); };
4283
+ }
4230
4284
  }
4231
4285
 
4232
4286
  /**
@@ -5399,7 +5453,7 @@ Object.defineProperty(Vue, 'FunctionalRenderContext', {
5399
5453
  value: FunctionalRenderContext
5400
5454
  });
5401
5455
 
5402
- Vue.version = '2.6.6';
5456
+ Vue.version = '2.6.10';
5403
5457
 
5404
5458
  /* */
5405
5459
 
@@ -7493,8 +7547,10 @@ function add$1 (
7493
7547
  e.target === e.currentTarget ||
7494
7548
  // event is fired after handler attachment
7495
7549
  e.timeStamp >= attachedTimestamp ||
7496
- // #9462 bail for iOS 9 bug: event.timeStamp is 0 after history.pushState
7497
- e.timeStamp === 0 ||
7550
+ // bail for environments that have buggy event.timeStamp implementations
7551
+ // #9462 iOS 9 bug: event.timeStamp is 0 after history.pushState
7552
+ // #9681 QtWebEngine event.timeStamp is negative value
7553
+ e.timeStamp <= 0 ||
7498
7554
  // #9448 bail if event is fired in another document in a multi-page
7499
7555
  // electron/nw.js app, since event.timeStamp will be using a different
7500
7556
  // starting reference
@@ -7561,10 +7617,11 @@ function updateDOMProps (oldVnode, vnode) {
7561
7617
  }
7562
7618
 
7563
7619
  for (key in oldProps) {
7564
- if (isUndef(props[key])) {
7620
+ if (!(key in props)) {
7565
7621
  elm[key] = '';
7566
7622
  }
7567
7623
  }
7624
+
7568
7625
  for (key in props) {
7569
7626
  cur = props[key];
7570
7627
  // ignore children if the node has textContent or innerHTML,
@@ -7580,15 +7637,7 @@ function updateDOMProps (oldVnode, vnode) {
7580
7637
  }
7581
7638
  }
7582
7639
 
7583
- // skip the update if old and new VDOM state is the same.
7584
- // the only exception is `value` where the DOM value may be temporarily
7585
- // out of sync with VDOM state due to focus, composition and modifiers.
7586
- // This also covers #4521 by skipping the unnecesarry `checked` update.
7587
- if (key !== 'value' && cur === oldProps[key]) {
7588
- continue
7589
- }
7590
-
7591
- if (key === 'value') {
7640
+ if (key === 'value' && elm.tagName !== 'PROGRESS') {
7592
7641
  // store value as _value as well since
7593
7642
  // non-string values will be stringified
7594
7643
  elm._value = cur;
@@ -7608,8 +7657,18 @@ function updateDOMProps (oldVnode, vnode) {
7608
7657
  while (svg.firstChild) {
7609
7658
  elm.appendChild(svg.firstChild);
7610
7659
  }
7611
- } else {
7612
- elm[key] = cur;
7660
+ } else if (
7661
+ // skip the update if old and new VDOM state is the same.
7662
+ // `value` is handled separately because the DOM value may be temporarily
7663
+ // out of sync with VDOM state due to focus, composition and modifiers.
7664
+ // This #4521 by skipping the unnecesarry `checked` update.
7665
+ cur !== oldProps[key]
7666
+ ) {
7667
+ // some property updates can throw
7668
+ // e.g. `value` on <progress> w/ non-finite value
7669
+ try {
7670
+ elm[key] = cur;
7671
+ } catch (e) {}
7613
7672
  }
7614
7673
  }
7615
7674
  }
@@ -8110,8 +8169,8 @@ function enter (vnode, toggleDisplay) {
8110
8169
  var context = activeInstance;
8111
8170
  var transitionNode = activeInstance.$vnode;
8112
8171
  while (transitionNode && transitionNode.parent) {
8113
- transitionNode = transitionNode.parent;
8114
8172
  context = transitionNode.context;
8173
+ transitionNode = transitionNode.parent;
8115
8174
  }
8116
8175
 
8117
8176
  var isAppear = !context._isMounted || !vnode.isRootInsert;
@@ -9207,7 +9266,7 @@ var isNonPhrasingTag = makeMap(
9207
9266
  // Regular Expressions for parsing tags and attributes
9208
9267
  var attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
9209
9268
  var dynamicArgAttribute = /^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
9210
- var ncname = "[a-zA-Z_][\\-\\.0-9_a-zA-Z" + unicodeLetters + "]*";
9269
+ var ncname = "[a-zA-Z_][\\-\\.0-9_a-zA-Z" + (unicodeRegExp.source) + "]*";
9211
9270
  var qnameCapture = "((?:" + ncname + "\\:)?" + ncname + ")";
9212
9271
  var startTagOpen = new RegExp(("^<" + qnameCapture));
9213
9272
  var startTagClose = /^\s*(\/?)>/;
@@ -9470,7 +9529,7 @@ function parseHTML (html, options) {
9470
9529
  ) {
9471
9530
  options.warn(
9472
9531
  ("tag <" + (stack[i].tag) + "> has no matching end tag."),
9473
- { start: stack[i].start }
9532
+ { start: stack[i].start, end: stack[i].end }
9474
9533
  );
9475
9534
  }
9476
9535
  if (options.end) {
@@ -9507,7 +9566,7 @@ var dynamicArgRE = /^\[.*\]$/;
9507
9566
 
9508
9567
  var argRE = /:(.*)$/;
9509
9568
  var bindRE = /^:|^\.|^v-bind:/;
9510
- var modifierRE = /\.[^.]+/g;
9569
+ var modifierRE = /\.[^.\]]+(?=[^\]]*$)/g;
9511
9570
 
9512
9571
  var slotRE = /^v-slot(:|$)|^#/;
9513
9572
 
@@ -9684,7 +9743,7 @@ function parse (
9684
9743
  shouldDecodeNewlinesForHref: options.shouldDecodeNewlinesForHref,
9685
9744
  shouldKeepComment: options.comments,
9686
9745
  outputSourceRange: options.outputSourceRange,
9687
- start: function start (tag, attrs, unary, start$1) {
9746
+ start: function start (tag, attrs, unary, start$1, end) {
9688
9747
  // check namespace.
9689
9748
  // inherit parent ns if there is one
9690
9749
  var ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag);
@@ -9703,6 +9762,7 @@ function parse (
9703
9762
  if (process.env.NODE_ENV !== 'production') {
9704
9763
  if (options.outputSourceRange) {
9705
9764
  element.start = start$1;
9765
+ element.end = end;
9706
9766
  element.rawAttrsMap = element.attrsList.reduce(function (cumulated, attr) {
9707
9767
  cumulated[attr.name] = attr;
9708
9768
  return cumulated
@@ -9824,7 +9884,7 @@ function parse (
9824
9884
  text = preserveWhitespace ? ' ' : '';
9825
9885
  }
9826
9886
  if (text) {
9827
- if (whitespaceOption === 'condense') {
9887
+ if (!inPre && whitespaceOption === 'condense') {
9828
9888
  // condense consecutive whitespaces into single space
9829
9889
  text = text.replace(whitespaceRE$1, ' ');
9830
9890
  }
@@ -10687,7 +10747,7 @@ function isDirectChildOfTemplateFor (node) {
10687
10747
 
10688
10748
  /* */
10689
10749
 
10690
- var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function\s*\(/;
10750
+ var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function\s*(?:[\w$]+)?\s*\(/;
10691
10751
  var fnInvokeRE = /\([^)]*?\);*$/;
10692
10752
  var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
10693
10753
 
@@ -11192,7 +11252,7 @@ function genScopedSlots (
11192
11252
  // components with only scoped slots to skip forced updates from parent.
11193
11253
  // but in some cases we have to bail-out of this optimization
11194
11254
  // for example if the slot contains dynamic names, has v-if or v-for on them...
11195
- var needsForceUpdate = Object.keys(slots).some(function (key) {
11255
+ var needsForceUpdate = el.for || Object.keys(slots).some(function (key) {
11196
11256
  var slot = slots[key];
11197
11257
  return (
11198
11258
  slot.slotTargetDynamic ||
@@ -11201,22 +11261,49 @@ function genScopedSlots (
11201
11261
  containsSlotChild(slot) // is passing down slot from parent which may be dynamic
11202
11262
  )
11203
11263
  });
11204
- // OR when it is inside another scoped slot (the reactivity is disconnected)
11205
- // #9438
11264
+
11265
+ // #9534: if a component with scoped slots is inside a conditional branch,
11266
+ // it's possible for the same component to be reused but with different
11267
+ // compiled slot content. To avoid that, we generate a unique key based on
11268
+ // the generated code of all the slot contents.
11269
+ var needsKey = !!el.if;
11270
+
11271
+ // OR when it is inside another scoped slot or v-for (the reactivity may be
11272
+ // disconnected due to the intermediate scope variable)
11273
+ // #9438, #9506
11274
+ // TODO: this can be further optimized by properly analyzing in-scope bindings
11275
+ // and skip force updating ones that do not actually use scope variables.
11206
11276
  if (!needsForceUpdate) {
11207
11277
  var parent = el.parent;
11208
11278
  while (parent) {
11209
- if (parent.slotScope && parent.slotScope !== emptySlotScopeToken) {
11279
+ if (
11280
+ (parent.slotScope && parent.slotScope !== emptySlotScopeToken) ||
11281
+ parent.for
11282
+ ) {
11210
11283
  needsForceUpdate = true;
11211
11284
  break
11212
11285
  }
11286
+ if (parent.if) {
11287
+ needsKey = true;
11288
+ }
11213
11289
  parent = parent.parent;
11214
11290
  }
11215
11291
  }
11216
11292
 
11217
- return ("scopedSlots:_u([" + (Object.keys(slots).map(function (key) {
11218
- return genScopedSlot(slots[key], state)
11219
- }).join(',')) + "]" + (needsForceUpdate ? ",true" : "") + ")")
11293
+ var generatedSlots = Object.keys(slots)
11294
+ .map(function (key) { return genScopedSlot(slots[key], state); })
11295
+ .join(',');
11296
+
11297
+ return ("scopedSlots:_u([" + generatedSlots + "]" + (needsForceUpdate ? ",null,true" : "") + (!needsForceUpdate && needsKey ? (",null,false," + (hash(generatedSlots))) : "") + ")")
11298
+ }
11299
+
11300
+ function hash(str) {
11301
+ var hash = 5381;
11302
+ var i = str.length;
11303
+ while(i) {
11304
+ hash = (hash * 33) ^ str.charCodeAt(--i);
11305
+ }
11306
+ return hash >>> 0
11220
11307
  }
11221
11308
 
11222
11309
  function containsSlotChild (el) {
@@ -11551,11 +11638,13 @@ function generateCodeFrame (
11551
11638
 
11552
11639
  function repeat$1 (str, n) {
11553
11640
  var result = '';
11554
- while (true) { // eslint-disable-line
11555
- if (n & 1) { result += str; }
11556
- n >>>= 1;
11557
- if (n <= 0) { break }
11558
- str += str;
11641
+ if (n > 0) {
11642
+ while (true) { // eslint-disable-line
11643
+ if (n & 1) { result += str; }
11644
+ n >>>= 1;
11645
+ if (n <= 0) { break }
11646
+ str += str;
11647
+ }
11559
11648
  }
11560
11649
  return result
11561
11650
  }