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.
@@ -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
- const 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
+ const 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
- const bailRE = new RegExp(`[^${unicodeLetters}.$_\\d]`);
503
+ const bailRE = new RegExp(`[^${unicodeRegExp.source}.$_\\d]`);
504
504
  function parsePath (path) {
505
505
  if (bailRE.test(path)) {
506
506
  return
@@ -1440,7 +1440,7 @@ function checkComponents (options) {
1440
1440
  }
1441
1441
 
1442
1442
  function validateComponentName (name) {
1443
- if (!new RegExp(`^[a-zA-Z][\\-\\.0-9_${unicodeLetters}]*$`).test(name)) {
1443
+ if (!new RegExp(`^[a-zA-Z][\\-\\.0-9_${unicodeRegExp.source}]*$`).test(name)) {
1444
1444
  warn(
1445
1445
  'Invalid component name: "' + name + '". Component names ' +
1446
1446
  'should conform to valid custom element name in html5 specification.'
@@ -1852,23 +1852,30 @@ function isBoolean (...args) {
1852
1852
  /* */
1853
1853
 
1854
1854
  function handleError (err, vm, info) {
1855
- if (vm) {
1856
- let cur = vm;
1857
- while ((cur = cur.$parent)) {
1858
- const hooks = cur.$options.errorCaptured;
1859
- if (hooks) {
1860
- for (let i = 0; i < hooks.length; i++) {
1861
- try {
1862
- const capture = hooks[i].call(cur, err, vm, info) === false;
1863
- if (capture) return
1864
- } catch (e) {
1865
- globalHandleError(e, cur, 'errorCaptured hook');
1855
+ // Deactivate deps tracking while processing error handler to avoid possible infinite rendering.
1856
+ // See: https://github.com/vuejs/vuex/issues/1505
1857
+ pushTarget();
1858
+ try {
1859
+ if (vm) {
1860
+ let cur = vm;
1861
+ while ((cur = cur.$parent)) {
1862
+ const hooks = cur.$options.errorCaptured;
1863
+ if (hooks) {
1864
+ for (let i = 0; i < hooks.length; i++) {
1865
+ try {
1866
+ const capture = hooks[i].call(cur, err, vm, info) === false;
1867
+ if (capture) return
1868
+ } catch (e) {
1869
+ globalHandleError(e, cur, 'errorCaptured hook');
1870
+ }
1866
1871
  }
1867
1872
  }
1868
1873
  }
1869
1874
  }
1875
+ globalHandleError(err, vm, info);
1876
+ } finally {
1877
+ popTarget();
1870
1878
  }
1871
- globalHandleError(err, vm, info);
1872
1879
  }
1873
1880
 
1874
1881
  function invokeWithErrorHandling (
@@ -1882,7 +1889,9 @@ function invokeWithErrorHandling (
1882
1889
  try {
1883
1890
  res = args ? handler.apply(context, args) : handler.call(context);
1884
1891
  if (res && !res._isVue && isPromise(res)) {
1885
- res.catch(e => handleError(e, vm, info + ` (Promise/async)`));
1892
+ // issue #9511
1893
+ // reassign to res to avoid catch triggering multiple times when nested calls
1894
+ res = res.catch(e => handleError(e, vm, info + ` (Promise/async)`));
1886
1895
  }
1887
1896
  } catch (e) {
1888
1897
  handleError(e, vm, info);
@@ -2562,13 +2571,22 @@ function normalizeScopedSlots (
2562
2571
  prevSlots
2563
2572
  ) {
2564
2573
  let res;
2574
+ const isStable = slots ? !!slots.$stable : true;
2575
+ const key = slots && slots.$key;
2565
2576
  if (!slots) {
2566
2577
  res = {};
2567
2578
  } else if (slots._normalized) {
2568
2579
  // fast path 1: child component re-render only, parent did not change
2569
2580
  return slots._normalized
2570
- } else if (slots.$stable && prevSlots && prevSlots !== emptyObject) {
2571
- // fast path 2: stable scoped slots, only need to normalize once
2581
+ } else if (
2582
+ isStable &&
2583
+ prevSlots &&
2584
+ prevSlots !== emptyObject &&
2585
+ key === prevSlots.$key &&
2586
+ Object.keys(normalSlots).length === 0
2587
+ ) {
2588
+ // fast path 2: stable scoped slots w/ no normal slots to proxy,
2589
+ // only need to normalize once
2572
2590
  return prevSlots
2573
2591
  } else {
2574
2592
  res = {};
@@ -2589,13 +2607,14 @@ function normalizeScopedSlots (
2589
2607
  if (slots && Object.isExtensible(slots)) {
2590
2608
  (slots)._normalized = res;
2591
2609
  }
2592
- def(res, '$stable', slots ? !!slots.$stable : true);
2610
+ def(res, '$stable', isStable);
2611
+ def(res, '$key', key);
2593
2612
  return res
2594
2613
  }
2595
2614
 
2596
2615
  function normalizeScopedSlot(normalSlots, key, fn) {
2597
- const normalized = scope => {
2598
- let res = fn(scope || {});
2616
+ const normalized = function () {
2617
+ let res = arguments.length ? fn.apply(null, arguments) : fn({});
2599
2618
  res = res && typeof res === 'object' && !Array.isArray(res)
2600
2619
  ? [res] // single vnode
2601
2620
  : normalizeChildren(res);
@@ -2882,14 +2901,16 @@ function bindObjectListeners (data, value) {
2882
2901
 
2883
2902
  function resolveScopedSlots (
2884
2903
  fns, // see flow/vnode
2904
+ res,
2905
+ // the following are added in 2.6
2885
2906
  hasDynamicKeys,
2886
- res
2907
+ contentHashKey
2887
2908
  ) {
2888
2909
  res = res || { $stable: !hasDynamicKeys };
2889
2910
  for (let i = 0; i < fns.length; i++) {
2890
2911
  const slot = fns[i];
2891
2912
  if (Array.isArray(slot)) {
2892
- resolveScopedSlots(slot, hasDynamicKeys, res);
2913
+ resolveScopedSlots(slot, res, hasDynamicKeys);
2893
2914
  } else if (slot) {
2894
2915
  // marker for reverse proxying v-slot without scope on this.$slots
2895
2916
  if (slot.proxy) {
@@ -2898,6 +2919,9 @@ function resolveScopedSlots (
2898
2919
  res[slot.key] = slot.fn;
2899
2920
  }
2900
2921
  }
2922
+ if (contentHashKey) {
2923
+ (res).$key = contentHashKey;
2924
+ }
2901
2925
  return res
2902
2926
  }
2903
2927
 
@@ -3607,17 +3631,21 @@ function resolveAsyncComponent (
3607
3631
  return factory.resolved
3608
3632
  }
3609
3633
 
3634
+ const owner = currentRenderingInstance;
3635
+ if (isDef(factory.owners) && factory.owners.indexOf(owner) === -1) {
3636
+ // already pending
3637
+ factory.owners.push(owner);
3638
+ }
3639
+
3610
3640
  if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
3611
3641
  return factory.loadingComp
3612
3642
  }
3613
3643
 
3614
- const owner = currentRenderingInstance;
3615
- if (isDef(factory.owners)) {
3616
- // already pending
3617
- factory.owners.push(owner);
3618
- } else {
3644
+ if (!isDef(factory.owners)) {
3619
3645
  const owners = factory.owners = [owner];
3620
- let sync = true;
3646
+ let sync = true
3647
+
3648
+ ;(owner).$on('hook:destroyed', () => remove(owners, owner));
3621
3649
 
3622
3650
  const forceRender = (renderCompleted) => {
3623
3651
  for (let i = 0, l = owners.length; i < l; i++) {
@@ -4070,9 +4098,12 @@ function updateChildComponent (
4070
4098
  // check if there are dynamic scopedSlots (hand-written or compiled but with
4071
4099
  // dynamic slot names). Static scoped slots compiled from template has the
4072
4100
  // "$stable" marker.
4101
+ const newScopedSlots = parentVnode.data.scopedSlots;
4102
+ const oldScopedSlots = vm.$scopedSlots;
4073
4103
  const hasDynamicScopedSlot = !!(
4074
- (parentVnode.data.scopedSlots && !parentVnode.data.scopedSlots.$stable) ||
4075
- (vm.$scopedSlots !== emptyObject && !vm.$scopedSlots.$stable)
4104
+ (newScopedSlots && !newScopedSlots.$stable) ||
4105
+ (oldScopedSlots !== emptyObject && !oldScopedSlots.$stable) ||
4106
+ (newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key)
4076
4107
  );
4077
4108
 
4078
4109
  // Any static slot children from the parent may have changed during parent's
@@ -5404,7 +5435,7 @@ Object.defineProperty(Vue, 'FunctionalRenderContext', {
5404
5435
  value: FunctionalRenderContext
5405
5436
  });
5406
5437
 
5407
- Vue.version = '2.6.4';
5438
+ Vue.version = '2.6.8';
5408
5439
 
5409
5440
  /* */
5410
5441
 
@@ -7482,9 +7513,17 @@ function add$1 (
7482
7513
  const original = handler;
7483
7514
  handler = original._wrapper = function (e) {
7484
7515
  if (
7516
+ // no bubbling, should always fire.
7517
+ // this is just a safety net in case event.timeStamp is unreliable in
7518
+ // certain weird environments...
7519
+ e.target === e.currentTarget ||
7520
+ // event is fired after handler attachment
7485
7521
  e.timeStamp >= attachedTimestamp ||
7522
+ // #9462 bail for iOS 9 bug: event.timeStamp is 0 after history.pushState
7523
+ e.timeStamp === 0 ||
7486
7524
  // #9448 bail if event is fired in another document in a multi-page
7487
- // electron/nw.js app
7525
+ // electron/nw.js app, since event.timeStamp will be using a different
7526
+ // starting reference
7488
7527
  e.target.ownerDocument !== document
7489
7528
  ) {
7490
7529
  return original.apply(this, arguments)
@@ -7567,15 +7606,7 @@ function updateDOMProps (oldVnode, vnode) {
7567
7606
  }
7568
7607
  }
7569
7608
 
7570
- // skip the update if old and new VDOM state is the same.
7571
- // the only exception is `value` where the DOM value may be temporarily
7572
- // out of sync with VDOM state due to focus, composition and modifiers.
7573
- // This also covers #4521 by skipping the unnecesarry `checked` update.
7574
- if (key !== 'value' && cur === oldProps[key]) {
7575
- continue
7576
- }
7577
-
7578
- if (key === 'value') {
7609
+ if (key === 'value' && elm.tagName !== 'PROGRESS') {
7579
7610
  // store value as _value as well since
7580
7611
  // non-string values will be stringified
7581
7612
  elm._value = cur;
@@ -7595,8 +7626,18 @@ function updateDOMProps (oldVnode, vnode) {
7595
7626
  while (svg.firstChild) {
7596
7627
  elm.appendChild(svg.firstChild);
7597
7628
  }
7598
- } else {
7599
- elm[key] = cur;
7629
+ } else if (
7630
+ // skip the update if old and new VDOM state is the same.
7631
+ // `value` is handled separately because the DOM value may be temporarily
7632
+ // out of sync with VDOM state due to focus, composition and modifiers.
7633
+ // This #4521 by skipping the unnecesarry `checked` update.
7634
+ cur !== oldProps[key]
7635
+ ) {
7636
+ // some property updates can throw
7637
+ // e.g. `value` on <progress> w/ non-finite value
7638
+ try {
7639
+ elm[key] = cur;
7640
+ } catch (e) {}
7600
7641
  }
7601
7642
  }
7602
7643
  }
@@ -9182,7 +9223,7 @@ const isNonPhrasingTag = makeMap(
9182
9223
  // Regular Expressions for parsing tags and attributes
9183
9224
  const attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
9184
9225
  const dynamicArgAttribute = /^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
9185
- const ncname = `[a-zA-Z_][\\-\\.0-9_a-zA-Z${unicodeLetters}]*`;
9226
+ const ncname = `[a-zA-Z_][\\-\\.0-9_a-zA-Z${unicodeRegExp.source}]*`;
9186
9227
  const qnameCapture = `((?:${ncname}\\:)?${ncname})`;
9187
9228
  const startTagOpen = new RegExp(`^<${qnameCapture}`);
9188
9229
  const startTagClose = /^\s*(\/?)>/;
@@ -9444,7 +9485,7 @@ function parseHTML (html, options) {
9444
9485
  ) {
9445
9486
  options.warn(
9446
9487
  `tag <${stack[i].tag}> has no matching end tag.`,
9447
- { start: stack[i].start }
9488
+ { start: stack[i].start, end: stack[i].end }
9448
9489
  );
9449
9490
  }
9450
9491
  if (options.end) {
@@ -9481,7 +9522,7 @@ const dynamicArgRE = /^\[.*\]$/;
9481
9522
 
9482
9523
  const argRE = /:(.*)$/;
9483
9524
  const bindRE = /^:|^\.|^v-bind:/;
9484
- const modifierRE = /\.[^.]+/g;
9525
+ const modifierRE = /\.[^.\]]+(?=[^\]]*$)/g;
9485
9526
 
9486
9527
  const slotRE = /^v-slot(:|$)|^#/;
9487
9528
 
@@ -9658,7 +9699,7 @@ function parse (
9658
9699
  shouldDecodeNewlinesForHref: options.shouldDecodeNewlinesForHref,
9659
9700
  shouldKeepComment: options.comments,
9660
9701
  outputSourceRange: options.outputSourceRange,
9661
- start (tag, attrs, unary, start) {
9702
+ start (tag, attrs, unary, start, end) {
9662
9703
  // check namespace.
9663
9704
  // inherit parent ns if there is one
9664
9705
  const ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag);
@@ -9677,6 +9718,7 @@ function parse (
9677
9718
  {
9678
9719
  if (options.outputSourceRange) {
9679
9720
  element.start = start;
9721
+ element.end = end;
9680
9722
  element.rawAttrsMap = element.attrsList.reduce((cumulated, attr) => {
9681
9723
  cumulated[attr.name] = attr;
9682
9724
  return cumulated
@@ -10792,7 +10834,13 @@ function genHandler (handler) {
10792
10834
  }
10793
10835
 
10794
10836
  function genKeyFilter (keys) {
10795
- return `if(('keyCode' in $event)&&${keys.map(genFilterCode).join('&&')})return null;`
10837
+ return (
10838
+ // make sure the key filters only apply to KeyboardEvents
10839
+ // #9441: can't use 'keyCode' in $event because Chrome autofill fires fake
10840
+ // key events that do not have keyCode property...
10841
+ `if(!$event.type.indexOf('key')&&` +
10842
+ `${keys.map(genFilterCode).join('&&')})return null;`
10843
+ )
10796
10844
  }
10797
10845
 
10798
10846
  function genFilterCode (key) {
@@ -11197,28 +11245,72 @@ function genScopedSlots (
11197
11245
  // components with only scoped slots to skip forced updates from parent.
11198
11246
  // but in some cases we have to bail-out of this optimization
11199
11247
  // for example if the slot contains dynamic names, has v-if or v-for on them...
11200
- let needsForceUpdate = Object.keys(slots).some(key => {
11248
+ let needsForceUpdate = el.for || Object.keys(slots).some(key => {
11201
11249
  const slot = slots[key];
11202
- return slot.slotTargetDynamic || slot.if || slot.for
11250
+ return (
11251
+ slot.slotTargetDynamic ||
11252
+ slot.if ||
11253
+ slot.for ||
11254
+ containsSlotChild(slot) // is passing down slot from parent which may be dynamic
11255
+ )
11203
11256
  });
11204
- // OR when it is inside another scoped slot (the reactivity is disconnected)
11205
- // #9438
11257
+
11258
+ // #9534: if a component with scoped slots is inside a conditional branch,
11259
+ // it's possible for the same component to be reused but with different
11260
+ // compiled slot content. To avoid that, we generate a unique key based on
11261
+ // the generated code of all the slot contents.
11262
+ let needsKey = !!el.if;
11263
+
11264
+ // OR when it is inside another scoped slot or v-for (the reactivity may be
11265
+ // disconnected due to the intermediate scope variable)
11266
+ // #9438, #9506
11267
+ // TODO: this can be further optimized by properly analyzing in-scope bindings
11268
+ // and skip force updating ones that do not actually use scope variables.
11206
11269
  if (!needsForceUpdate) {
11207
11270
  let parent = el.parent;
11208
11271
  while (parent) {
11209
- if (parent.slotScope && parent.slotScope !== emptySlotScopeToken) {
11272
+ if (
11273
+ (parent.slotScope && parent.slotScope !== emptySlotScopeToken) ||
11274
+ parent.for
11275
+ ) {
11210
11276
  needsForceUpdate = true;
11211
11277
  break
11212
11278
  }
11279
+ if (parent.if) {
11280
+ needsKey = true;
11281
+ }
11213
11282
  parent = parent.parent;
11214
11283
  }
11215
11284
  }
11216
11285
 
11217
- return `scopedSlots:_u([${
11218
- Object.keys(slots).map(key => {
11219
- return genScopedSlot(slots[key], state)
11220
- }).join(',')
11221
- }]${needsForceUpdate ? `,true` : ``})`
11286
+ const generatedSlots = Object.keys(slots)
11287
+ .map(key => genScopedSlot(slots[key], state))
11288
+ .join(',');
11289
+
11290
+ return `scopedSlots:_u([${generatedSlots}]${
11291
+ needsForceUpdate ? `,null,true` : ``
11292
+ }${
11293
+ !needsForceUpdate && needsKey ? `,null,false,${hash(generatedSlots)}` : ``
11294
+ })`
11295
+ }
11296
+
11297
+ function hash(str) {
11298
+ let hash = 5381;
11299
+ let i = str.length;
11300
+ while(i) {
11301
+ hash = (hash * 33) ^ str.charCodeAt(--i);
11302
+ }
11303
+ return hash >>> 0
11304
+ }
11305
+
11306
+ function containsSlotChild (el) {
11307
+ if (el.type === 1) {
11308
+ if (el.tag === 'slot') {
11309
+ return true
11310
+ }
11311
+ return el.children.some(containsSlotChild)
11312
+ }
11313
+ return false
11222
11314
  }
11223
11315
 
11224
11316
  function genScopedSlot (
@@ -11546,11 +11638,13 @@ function generateCodeFrame (
11546
11638
 
11547
11639
  function repeat (str, n) {
11548
11640
  let result = '';
11549
- while (true) { // eslint-disable-line
11550
- if (n & 1) result += str;
11551
- n >>>= 1;
11552
- if (n <= 0) break
11553
- 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
+ }
11554
11648
  }
11555
11649
  return result
11556
11650
  }