vue 2.6.4 → 2.6.8

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.
package/dist/vue.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Vue.js v2.6.4
2
+ * Vue.js v2.6.8
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 (
@@ -1855,7 +1862,9 @@ function invokeWithErrorHandling (
1855
1862
  try {
1856
1863
  res = args ? handler.apply(context, args) : handler.call(context);
1857
1864
  if (res && !res._isVue && isPromise(res)) {
1858
- res.catch(function (e) { return handleError(e, vm, info + " (Promise/async)"); });
1865
+ // issue #9511
1866
+ // reassign to res to avoid catch triggering multiple times when nested calls
1867
+ res = res.catch(function (e) { return handleError(e, vm, info + " (Promise/async)"); });
1859
1868
  }
1860
1869
  } catch (e) {
1861
1870
  handleError(e, vm, info);
@@ -2540,26 +2549,35 @@ function normalizeScopedSlots (
2540
2549
  prevSlots
2541
2550
  ) {
2542
2551
  var res;
2552
+ var isStable = slots ? !!slots.$stable : true;
2553
+ var key = slots && slots.$key;
2543
2554
  if (!slots) {
2544
2555
  res = {};
2545
2556
  } else if (slots._normalized) {
2546
2557
  // fast path 1: child component re-render only, parent did not change
2547
2558
  return slots._normalized
2548
- } else if (slots.$stable && prevSlots && prevSlots !== emptyObject) {
2549
- // fast path 2: stable scoped slots, only need to normalize once
2559
+ } else if (
2560
+ isStable &&
2561
+ prevSlots &&
2562
+ prevSlots !== emptyObject &&
2563
+ key === prevSlots.$key &&
2564
+ Object.keys(normalSlots).length === 0
2565
+ ) {
2566
+ // fast path 2: stable scoped slots w/ no normal slots to proxy,
2567
+ // only need to normalize once
2550
2568
  return prevSlots
2551
2569
  } else {
2552
2570
  res = {};
2553
- for (var key in slots) {
2554
- if (slots[key] && key[0] !== '$') {
2555
- res[key] = normalizeScopedSlot(normalSlots, key, slots[key]);
2571
+ for (var key$1 in slots) {
2572
+ if (slots[key$1] && key$1[0] !== '$') {
2573
+ res[key$1] = normalizeScopedSlot(normalSlots, key$1, slots[key$1]);
2556
2574
  }
2557
2575
  }
2558
2576
  }
2559
2577
  // expose normal slots on scopedSlots
2560
- for (var key$1 in normalSlots) {
2561
- if (!(key$1 in res)) {
2562
- res[key$1] = proxyNormalSlot(normalSlots, key$1);
2578
+ for (var key$2 in normalSlots) {
2579
+ if (!(key$2 in res)) {
2580
+ res[key$2] = proxyNormalSlot(normalSlots, key$2);
2563
2581
  }
2564
2582
  }
2565
2583
  // avoriaz seems to mock a non-extensible $scopedSlots object
@@ -2567,13 +2585,14 @@ function normalizeScopedSlots (
2567
2585
  if (slots && Object.isExtensible(slots)) {
2568
2586
  (slots)._normalized = res;
2569
2587
  }
2570
- def(res, '$stable', slots ? !!slots.$stable : true);
2588
+ def(res, '$stable', isStable);
2589
+ def(res, '$key', key);
2571
2590
  return res
2572
2591
  }
2573
2592
 
2574
2593
  function normalizeScopedSlot(normalSlots, key, fn) {
2575
- var normalized = function (scope) {
2576
- var res = fn(scope || {});
2594
+ var normalized = function () {
2595
+ var res = arguments.length ? fn.apply(null, arguments) : fn({});
2577
2596
  res = res && typeof res === 'object' && !Array.isArray(res)
2578
2597
  ? [res] // single vnode
2579
2598
  : normalizeChildren(res);
@@ -2862,14 +2881,16 @@ function bindObjectListeners (data, value) {
2862
2881
 
2863
2882
  function resolveScopedSlots (
2864
2883
  fns, // see flow/vnode
2884
+ res,
2885
+ // the following are added in 2.6
2865
2886
  hasDynamicKeys,
2866
- res
2887
+ contentHashKey
2867
2888
  ) {
2868
2889
  res = res || { $stable: !hasDynamicKeys };
2869
2890
  for (var i = 0; i < fns.length; i++) {
2870
2891
  var slot = fns[i];
2871
2892
  if (Array.isArray(slot)) {
2872
- resolveScopedSlots(slot, hasDynamicKeys, res);
2893
+ resolveScopedSlots(slot, res, hasDynamicKeys);
2873
2894
  } else if (slot) {
2874
2895
  // marker for reverse proxying v-slot without scope on this.$slots
2875
2896
  if (slot.proxy) {
@@ -2878,6 +2899,9 @@ function resolveScopedSlots (
2878
2899
  res[slot.key] = slot.fn;
2879
2900
  }
2880
2901
  }
2902
+ if (contentHashKey) {
2903
+ (res).$key = contentHashKey;
2904
+ }
2881
2905
  return res
2882
2906
  }
2883
2907
 
@@ -3596,17 +3620,21 @@ function resolveAsyncComponent (
3596
3620
  return factory.resolved
3597
3621
  }
3598
3622
 
3623
+ var owner = currentRenderingInstance;
3624
+ if (isDef(factory.owners) && factory.owners.indexOf(owner) === -1) {
3625
+ // already pending
3626
+ factory.owners.push(owner);
3627
+ }
3628
+
3599
3629
  if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
3600
3630
  return factory.loadingComp
3601
3631
  }
3602
3632
 
3603
- var owner = currentRenderingInstance;
3604
- if (isDef(factory.owners)) {
3605
- // already pending
3606
- factory.owners.push(owner);
3607
- } else {
3633
+ if (!isDef(factory.owners)) {
3608
3634
  var owners = factory.owners = [owner];
3609
- var sync = true;
3635
+ var sync = true
3636
+
3637
+ ;(owner).$on('hook:destroyed', function () { return remove(owners, owner); });
3610
3638
 
3611
3639
  var forceRender = function (renderCompleted) {
3612
3640
  for (var i = 0, l = owners.length; i < l; i++) {
@@ -4061,9 +4089,12 @@ function updateChildComponent (
4061
4089
  // check if there are dynamic scopedSlots (hand-written or compiled but with
4062
4090
  // dynamic slot names). Static scoped slots compiled from template has the
4063
4091
  // "$stable" marker.
4092
+ var newScopedSlots = parentVnode.data.scopedSlots;
4093
+ var oldScopedSlots = vm.$scopedSlots;
4064
4094
  var hasDynamicScopedSlot = !!(
4065
- (parentVnode.data.scopedSlots && !parentVnode.data.scopedSlots.$stable) ||
4066
- (vm.$scopedSlots !== emptyObject && !vm.$scopedSlots.$stable)
4095
+ (newScopedSlots && !newScopedSlots.$stable) ||
4096
+ (oldScopedSlots !== emptyObject && !oldScopedSlots.$stable) ||
4097
+ (newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key)
4067
4098
  );
4068
4099
 
4069
4100
  // Any static slot children from the parent may have changed during parent's
@@ -5393,7 +5424,7 @@ Object.defineProperty(Vue, 'FunctionalRenderContext', {
5393
5424
  value: FunctionalRenderContext
5394
5425
  });
5395
5426
 
5396
- Vue.version = '2.6.4';
5427
+ Vue.version = '2.6.8';
5397
5428
 
5398
5429
  /* */
5399
5430
 
@@ -7481,9 +7512,17 @@ function add$1 (
7481
7512
  var original = handler;
7482
7513
  handler = original._wrapper = function (e) {
7483
7514
  if (
7515
+ // no bubbling, should always fire.
7516
+ // this is just a safety net in case event.timeStamp is unreliable in
7517
+ // certain weird environments...
7518
+ e.target === e.currentTarget ||
7519
+ // event is fired after handler attachment
7484
7520
  e.timeStamp >= attachedTimestamp ||
7521
+ // #9462 bail for iOS 9 bug: event.timeStamp is 0 after history.pushState
7522
+ e.timeStamp === 0 ||
7485
7523
  // #9448 bail if event is fired in another document in a multi-page
7486
- // electron/nw.js app
7524
+ // electron/nw.js app, since event.timeStamp will be using a different
7525
+ // starting reference
7487
7526
  e.target.ownerDocument !== document
7488
7527
  ) {
7489
7528
  return original.apply(this, arguments)
@@ -7566,15 +7605,7 @@ function updateDOMProps (oldVnode, vnode) {
7566
7605
  }
7567
7606
  }
7568
7607
 
7569
- // skip the update if old and new VDOM state is the same.
7570
- // the only exception is `value` where the DOM value may be temporarily
7571
- // out of sync with VDOM state due to focus, composition and modifiers.
7572
- // This also covers #4521 by skipping the unnecesarry `checked` update.
7573
- if (key !== 'value' && cur === oldProps[key]) {
7574
- continue
7575
- }
7576
-
7577
- if (key === 'value') {
7608
+ if (key === 'value' && elm.tagName !== 'PROGRESS') {
7578
7609
  // store value as _value as well since
7579
7610
  // non-string values will be stringified
7580
7611
  elm._value = cur;
@@ -7594,8 +7625,18 @@ function updateDOMProps (oldVnode, vnode) {
7594
7625
  while (svg.firstChild) {
7595
7626
  elm.appendChild(svg.firstChild);
7596
7627
  }
7597
- } else {
7598
- elm[key] = cur;
7628
+ } else if (
7629
+ // skip the update if old and new VDOM state is the same.
7630
+ // `value` is handled separately because the DOM value may be temporarily
7631
+ // out of sync with VDOM state due to focus, composition and modifiers.
7632
+ // This #4521 by skipping the unnecesarry `checked` update.
7633
+ cur !== oldProps[key]
7634
+ ) {
7635
+ // some property updates can throw
7636
+ // e.g. `value` on <progress> w/ non-finite value
7637
+ try {
7638
+ elm[key] = cur;
7639
+ } catch (e) {}
7599
7640
  }
7600
7641
  }
7601
7642
  }
@@ -9193,7 +9234,7 @@ var isNonPhrasingTag = makeMap(
9193
9234
  // Regular Expressions for parsing tags and attributes
9194
9235
  var attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
9195
9236
  var dynamicArgAttribute = /^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
9196
- var ncname = "[a-zA-Z_][\\-\\.0-9_a-zA-Z" + unicodeLetters + "]*";
9237
+ var ncname = "[a-zA-Z_][\\-\\.0-9_a-zA-Z" + (unicodeRegExp.source) + "]*";
9197
9238
  var qnameCapture = "((?:" + ncname + "\\:)?" + ncname + ")";
9198
9239
  var startTagOpen = new RegExp(("^<" + qnameCapture));
9199
9240
  var startTagClose = /^\s*(\/?)>/;
@@ -9456,7 +9497,7 @@ function parseHTML (html, options) {
9456
9497
  ) {
9457
9498
  options.warn(
9458
9499
  ("tag <" + (stack[i].tag) + "> has no matching end tag."),
9459
- { start: stack[i].start }
9500
+ { start: stack[i].start, end: stack[i].end }
9460
9501
  );
9461
9502
  }
9462
9503
  if (options.end) {
@@ -9493,7 +9534,7 @@ var dynamicArgRE = /^\[.*\]$/;
9493
9534
 
9494
9535
  var argRE = /:(.*)$/;
9495
9536
  var bindRE = /^:|^\.|^v-bind:/;
9496
- var modifierRE = /\.[^.]+/g;
9537
+ var modifierRE = /\.[^.\]]+(?=[^\]]*$)/g;
9497
9538
 
9498
9539
  var slotRE = /^v-slot(:|$)|^#/;
9499
9540
 
@@ -9670,7 +9711,7 @@ function parse (
9670
9711
  shouldDecodeNewlinesForHref: options.shouldDecodeNewlinesForHref,
9671
9712
  shouldKeepComment: options.comments,
9672
9713
  outputSourceRange: options.outputSourceRange,
9673
- start: function start (tag, attrs, unary, start$1) {
9714
+ start: function start (tag, attrs, unary, start$1, end) {
9674
9715
  // check namespace.
9675
9716
  // inherit parent ns if there is one
9676
9717
  var ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag);
@@ -9689,6 +9730,7 @@ function parse (
9689
9730
  if (process.env.NODE_ENV !== 'production') {
9690
9731
  if (options.outputSourceRange) {
9691
9732
  element.start = start$1;
9733
+ element.end = end;
9692
9734
  element.rawAttrsMap = element.attrsList.reduce(function (cumulated, attr) {
9693
9735
  cumulated[attr.name] = attr;
9694
9736
  return cumulated
@@ -10808,7 +10850,13 @@ function genHandler (handler) {
10808
10850
  }
10809
10851
 
10810
10852
  function genKeyFilter (keys) {
10811
- return ("if(('keyCode' in $event)&&" + (keys.map(genFilterCode).join('&&')) + ")return null;")
10853
+ return (
10854
+ // make sure the key filters only apply to KeyboardEvents
10855
+ // #9441: can't use 'keyCode' in $event because Chrome autofill fires fake
10856
+ // key events that do not have keyCode property...
10857
+ "if(!$event.type.indexOf('key')&&" +
10858
+ (keys.map(genFilterCode).join('&&')) + ")return null;"
10859
+ )
10812
10860
  }
10813
10861
 
10814
10862
  function genFilterCode (key) {
@@ -11172,26 +11220,68 @@ function genScopedSlots (
11172
11220
  // components with only scoped slots to skip forced updates from parent.
11173
11221
  // but in some cases we have to bail-out of this optimization
11174
11222
  // for example if the slot contains dynamic names, has v-if or v-for on them...
11175
- var needsForceUpdate = Object.keys(slots).some(function (key) {
11223
+ var needsForceUpdate = el.for || Object.keys(slots).some(function (key) {
11176
11224
  var slot = slots[key];
11177
- return slot.slotTargetDynamic || slot.if || slot.for
11225
+ return (
11226
+ slot.slotTargetDynamic ||
11227
+ slot.if ||
11228
+ slot.for ||
11229
+ containsSlotChild(slot) // is passing down slot from parent which may be dynamic
11230
+ )
11178
11231
  });
11179
- // OR when it is inside another scoped slot (the reactivity is disconnected)
11180
- // #9438
11232
+
11233
+ // #9534: if a component with scoped slots is inside a conditional branch,
11234
+ // it's possible for the same component to be reused but with different
11235
+ // compiled slot content. To avoid that, we generate a unique key based on
11236
+ // the generated code of all the slot contents.
11237
+ var needsKey = !!el.if;
11238
+
11239
+ // OR when it is inside another scoped slot or v-for (the reactivity may be
11240
+ // disconnected due to the intermediate scope variable)
11241
+ // #9438, #9506
11242
+ // TODO: this can be further optimized by properly analyzing in-scope bindings
11243
+ // and skip force updating ones that do not actually use scope variables.
11181
11244
  if (!needsForceUpdate) {
11182
11245
  var parent = el.parent;
11183
11246
  while (parent) {
11184
- if (parent.slotScope && parent.slotScope !== emptySlotScopeToken) {
11247
+ if (
11248
+ (parent.slotScope && parent.slotScope !== emptySlotScopeToken) ||
11249
+ parent.for
11250
+ ) {
11185
11251
  needsForceUpdate = true;
11186
11252
  break
11187
11253
  }
11254
+ if (parent.if) {
11255
+ needsKey = true;
11256
+ }
11188
11257
  parent = parent.parent;
11189
11258
  }
11190
11259
  }
11191
11260
 
11192
- return ("scopedSlots:_u([" + (Object.keys(slots).map(function (key) {
11193
- return genScopedSlot(slots[key], state)
11194
- }).join(',')) + "]" + (needsForceUpdate ? ",true" : "") + ")")
11261
+ var generatedSlots = Object.keys(slots)
11262
+ .map(function (key) { return genScopedSlot(slots[key], state); })
11263
+ .join(',');
11264
+
11265
+ return ("scopedSlots:_u([" + generatedSlots + "]" + (needsForceUpdate ? ",null,true" : "") + (!needsForceUpdate && needsKey ? (",null,false," + (hash(generatedSlots))) : "") + ")")
11266
+ }
11267
+
11268
+ function hash(str) {
11269
+ var hash = 5381;
11270
+ var i = str.length;
11271
+ while(i) {
11272
+ hash = (hash * 33) ^ str.charCodeAt(--i);
11273
+ }
11274
+ return hash >>> 0
11275
+ }
11276
+
11277
+ function containsSlotChild (el) {
11278
+ if (el.type === 1) {
11279
+ if (el.tag === 'slot') {
11280
+ return true
11281
+ }
11282
+ return el.children.some(containsSlotChild)
11283
+ }
11284
+ return false
11195
11285
  }
11196
11286
 
11197
11287
  function genScopedSlot (
@@ -11516,11 +11606,13 @@ function generateCodeFrame (
11516
11606
 
11517
11607
  function repeat$1 (str, n) {
11518
11608
  var result = '';
11519
- while (true) { // eslint-disable-line
11520
- if (n & 1) { result += str; }
11521
- n >>>= 1;
11522
- if (n <= 0) { break }
11523
- str += str;
11609
+ if (n > 0) {
11610
+ while (true) { // eslint-disable-line
11611
+ if (n & 1) { result += str; }
11612
+ n >>>= 1;
11613
+ if (n <= 0) { break }
11614
+ str += str;
11615
+ }
11524
11616
  }
11525
11617
  return result
11526
11618
  }