vue 2.5.9 → 2.5.13

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 (70) hide show
  1. package/README.md +39 -31
  2. package/dist/vue.common.js +245 -153
  3. package/dist/vue.esm.js +245 -153
  4. package/dist/vue.js +240 -152
  5. package/dist/vue.min.js +2 -2
  6. package/dist/vue.runtime.common.js +155 -92
  7. package/dist/vue.runtime.esm.js +155 -92
  8. package/dist/vue.runtime.js +150 -91
  9. package/dist/vue.runtime.min.js +2 -2
  10. package/package.json +12 -12
  11. package/src/compiler/codegen/events.js +30 -3
  12. package/src/compiler/codegen/index.js +20 -9
  13. package/src/compiler/create-compiler.js +1 -1
  14. package/src/compiler/helpers.js +12 -1
  15. package/src/compiler/index.js +3 -1
  16. package/src/compiler/parser/index.js +39 -30
  17. package/src/compiler/parser/text-parser.js +17 -5
  18. package/src/compiler/to-function.js +1 -3
  19. package/src/core/config.js +2 -0
  20. package/src/core/global-api/assets.js +3 -9
  21. package/src/core/global-api/extend.js +3 -9
  22. package/src/core/instance/init.js +10 -6
  23. package/src/core/instance/inject.js +5 -5
  24. package/src/core/instance/lifecycle.js +1 -1
  25. package/src/core/instance/render-helpers/render-static.js +7 -13
  26. package/src/core/instance/render-helpers/resolve-slots.js +4 -2
  27. package/src/core/instance/state.js +2 -1
  28. package/src/core/observer/array.js +1 -2
  29. package/src/core/util/options.js +23 -12
  30. package/src/core/util/props.js +5 -1
  31. package/src/core/vdom/create-component.js +15 -6
  32. package/src/core/vdom/create-element.js +7 -5
  33. package/src/core/vdom/helpers/update-listeners.js +12 -5
  34. package/src/core/vdom/modules/directives.js +3 -0
  35. package/src/core/vdom/patch.js +26 -8
  36. package/src/platforms/web/compiler/directives/model.js +11 -11
  37. package/src/platforms/web/compiler/modules/class.js +2 -2
  38. package/src/platforms/web/compiler/modules/model.js +1 -5
  39. package/src/platforms/web/compiler/modules/style.js +2 -2
  40. package/src/platforms/web/runtime/modules/dom-props.js +15 -9
  41. package/src/platforms/web/util/class.js +3 -3
  42. package/src/platforms/web/util/style.js +5 -2
  43. package/src/platforms/weex/compiler/index.js +26 -4
  44. package/src/platforms/weex/compiler/modules/append.js +7 -1
  45. package/src/platforms/weex/compiler/modules/class.js +1 -1
  46. package/src/platforms/weex/compiler/modules/index.js +2 -0
  47. package/src/platforms/weex/compiler/modules/recycle-list/component-root.js +15 -0
  48. package/src/platforms/weex/compiler/modules/recycle-list/component.js +16 -0
  49. package/src/platforms/weex/compiler/modules/recycle-list/index.js +56 -0
  50. package/src/platforms/weex/compiler/modules/recycle-list/text.js +23 -0
  51. package/src/platforms/weex/compiler/modules/recycle-list/v-bind.js +22 -0
  52. package/src/platforms/weex/compiler/modules/recycle-list/v-for.js +33 -0
  53. package/src/platforms/weex/compiler/modules/recycle-list/v-if.js +47 -0
  54. package/src/platforms/weex/compiler/modules/recycle-list/v-on.js +25 -0
  55. package/src/platforms/weex/compiler/modules/style.js +1 -1
  56. package/src/platforms/weex/entry-framework.js +10 -51
  57. package/src/platforms/weex/runtime/index.js +1 -1
  58. package/src/platforms/weex/runtime/modules/events.js +4 -2
  59. package/src/platforms/weex/runtime/recycle-list/render-component-template.js +34 -0
  60. package/src/platforms/weex/runtime/recycle-list/virtual-component.js +136 -0
  61. package/src/platforms/weex/util/element.js +52 -0
  62. package/src/platforms/weex/util/index.js +35 -37
  63. package/src/server/create-renderer.js +6 -2
  64. package/src/server/optimizing-compiler/modules.js +1 -1
  65. package/src/server/render-context.js +1 -1
  66. package/src/server/render.js +4 -7
  67. package/src/server/template-renderer/index.js +2 -3
  68. package/src/sfc/parser.js +4 -4
  69. package/src/shared/util.js +2 -0
  70. package/types/vue.d.ts +13 -11
package/dist/vue.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Vue.js v2.5.9
2
+ * Vue.js v2.5.13
3
3
  * (c) 2014-2017 Evan You
4
4
  * Released under the MIT License.
5
5
  */
@@ -32,6 +32,8 @@ function isPrimitive (value) {
32
32
  return (
33
33
  typeof value === 'string' ||
34
34
  typeof value === 'number' ||
35
+ // $flow-disable-line
36
+ typeof value === 'symbol' ||
35
37
  typeof value === 'boolean'
36
38
  )
37
39
  }
@@ -340,6 +342,7 @@ var config = ({
340
342
  /**
341
343
  * Option merge strategies (used in core/util/options)
342
344
  */
345
+ // $flow-disable-line
343
346
  optionMergeStrategies: Object.create(null),
344
347
 
345
348
  /**
@@ -380,6 +383,7 @@ var config = ({
380
383
  /**
381
384
  * Custom user key aliases for v-on
382
385
  */
386
+ // $flow-disable-line
383
387
  keyCodes: Object.create(null),
384
388
 
385
389
  /**
@@ -814,8 +818,7 @@ var arrayMethods = Object.create(arrayProto);[
814
818
  'splice',
815
819
  'sort',
816
820
  'reverse'
817
- ]
818
- .forEach(function (method) {
821
+ ].forEach(function (method) {
819
822
  // cache original method
820
823
  var original = arrayProto[method];
821
824
  def(arrayMethods, method, function mutator () {
@@ -1147,18 +1150,18 @@ function mergeDataOrFn (
1147
1150
  // it has to be a function to pass previous merges.
1148
1151
  return function mergedDataFn () {
1149
1152
  return mergeData(
1150
- typeof childVal === 'function' ? childVal.call(this) : childVal,
1151
- typeof parentVal === 'function' ? parentVal.call(this) : parentVal
1153
+ typeof childVal === 'function' ? childVal.call(this, this) : childVal,
1154
+ typeof parentVal === 'function' ? parentVal.call(this, this) : parentVal
1152
1155
  )
1153
1156
  }
1154
1157
  } else {
1155
1158
  return function mergedInstanceDataFn () {
1156
1159
  // instance merge
1157
1160
  var instanceData = typeof childVal === 'function'
1158
- ? childVal.call(vm)
1161
+ ? childVal.call(vm, vm)
1159
1162
  : childVal;
1160
1163
  var defaultData = typeof parentVal === 'function'
1161
- ? parentVal.call(vm)
1164
+ ? parentVal.call(vm, vm)
1162
1165
  : parentVal;
1163
1166
  if (instanceData) {
1164
1167
  return mergeData(instanceData, defaultData)
@@ -1310,13 +1313,23 @@ var defaultStrat = function (parentVal, childVal) {
1310
1313
  */
1311
1314
  function checkComponents (options) {
1312
1315
  for (var key in options.components) {
1313
- var lower = key.toLowerCase();
1314
- if (isBuiltInTag(lower) || config.isReservedTag(lower)) {
1315
- warn(
1316
- 'Do not use built-in or reserved HTML elements as component ' +
1317
- 'id: ' + key
1318
- );
1319
- }
1316
+ validateComponentName(key);
1317
+ }
1318
+ }
1319
+
1320
+ function validateComponentName (name) {
1321
+ if (!/^[a-zA-Z][\w-]*$/.test(name)) {
1322
+ warn(
1323
+ 'Invalid component name: "' + name + '". Component names ' +
1324
+ 'can only contain alphanumeric characters and the hyphen, ' +
1325
+ 'and must start with a letter.'
1326
+ );
1327
+ }
1328
+ if (isBuiltInTag(name) || config.isReservedTag(name)) {
1329
+ warn(
1330
+ 'Do not use built-in or reserved HTML elements as component ' +
1331
+ 'id: ' + name
1332
+ );
1320
1333
  }
1321
1334
  }
1322
1335
 
@@ -1363,6 +1376,7 @@ function normalizeProps (options, vm) {
1363
1376
  */
1364
1377
  function normalizeInject (options, vm) {
1365
1378
  var inject = options.inject;
1379
+ if (!inject) { return }
1366
1380
  var normalized = options.inject = {};
1367
1381
  if (Array.isArray(inject)) {
1368
1382
  for (var i = 0; i < inject.length; i++) {
@@ -1375,7 +1389,7 @@ function normalizeInject (options, vm) {
1375
1389
  ? extend({ from: key }, val)
1376
1390
  : { from: val };
1377
1391
  }
1378
- } else if (process.env.NODE_ENV !== 'production' && inject) {
1392
+ } else if (process.env.NODE_ENV !== 'production') {
1379
1393
  warn(
1380
1394
  "Invalid value for option \"inject\": expected an Array or an Object, " +
1381
1395
  "but got " + (toRawType(inject)) + ".",
@@ -1517,7 +1531,11 @@ function validateProp (
1517
1531
  observe(value);
1518
1532
  observerState.shouldConvert = prevShouldConvert;
1519
1533
  }
1520
- if (process.env.NODE_ENV !== 'production') {
1534
+ if (
1535
+ process.env.NODE_ENV !== 'production' &&
1536
+ // skip validation for weex recycle-list child component props
1537
+ !(false && isObject(value) && ('@binding' in value))
1538
+ ) {
1521
1539
  assertProp(prop, key, value, vm, absent);
1522
1540
  }
1523
1541
  return value
@@ -1997,11 +2015,12 @@ function updateListeners (
1997
2015
  remove$$1,
1998
2016
  vm
1999
2017
  ) {
2000
- var name, cur, old, event;
2018
+ var name, def, cur, old, event;
2001
2019
  for (name in on) {
2002
- cur = on[name];
2020
+ def = cur = on[name];
2003
2021
  old = oldOn[name];
2004
2022
  event = normalizeEvent(name);
2023
+ /* istanbul ignore if */
2005
2024
  if (isUndef(cur)) {
2006
2025
  process.env.NODE_ENV !== 'production' && warn(
2007
2026
  "Invalid handler for event \"" + (event.name) + "\": got " + String(cur),
@@ -2011,7 +2030,7 @@ function updateListeners (
2011
2030
  if (isUndef(cur.fns)) {
2012
2031
  cur = on[name] = createFnInvoker(cur);
2013
2032
  }
2014
- add(event.name, cur, event.once, event.capture, event.passive);
2033
+ add(event.name, cur, event.once, event.capture, event.passive, event.params);
2015
2034
  } else if (cur !== old) {
2016
2035
  old.fns = cur;
2017
2036
  on[name] = old;
@@ -2505,6 +2524,8 @@ function eventsMixin (Vue) {
2505
2524
 
2506
2525
  /* */
2507
2526
 
2527
+
2528
+
2508
2529
  /**
2509
2530
  * Runtime helper for resolving raw children VNodes into a slot object.
2510
2531
  */
@@ -2528,10 +2549,10 @@ function resolveSlots (
2528
2549
  if ((child.context === context || child.fnContext === context) &&
2529
2550
  data && data.slot != null
2530
2551
  ) {
2531
- var name = child.data.slot;
2552
+ var name = data.slot;
2532
2553
  var slot = (slots[name] || (slots[name] = []));
2533
2554
  if (child.tag === 'template') {
2534
- slot.push.apply(slot, child.children);
2555
+ slot.push.apply(slot, child.children || []);
2535
2556
  } else {
2536
2557
  slot.push(child);
2537
2558
  }
@@ -3372,6 +3393,7 @@ function getData (data, vm) {
3372
3393
  var computedWatcherOptions = { lazy: true };
3373
3394
 
3374
3395
  function initComputed (vm, computed) {
3396
+ // $flow-disable-line
3375
3397
  var watchers = vm._computedWatchers = Object.create(null);
3376
3398
  // computed properties are just getters during SSR
3377
3399
  var isSSR = isServerRendering();
@@ -3602,11 +3624,11 @@ function resolveInject (inject, vm) {
3602
3624
  // inject is :any because flow is not smart enough to figure out cached
3603
3625
  var result = Object.create(null);
3604
3626
  var keys = hasSymbol
3605
- ? Reflect.ownKeys(inject).filter(function (key) {
3606
- /* istanbul ignore next */
3607
- return Object.getOwnPropertyDescriptor(inject, key).enumerable
3608
- })
3609
- : Object.keys(inject);
3627
+ ? Reflect.ownKeys(inject).filter(function (key) {
3628
+ /* istanbul ignore next */
3629
+ return Object.getOwnPropertyDescriptor(inject, key).enumerable
3630
+ })
3631
+ : Object.keys(inject);
3610
3632
 
3611
3633
  for (var i = 0; i < keys.length; i++) {
3612
3634
  var key = keys[i];
@@ -3812,19 +3834,9 @@ function bindObjectProps (
3812
3834
  */
3813
3835
  function renderStatic (
3814
3836
  index,
3815
- isInFor,
3816
- isOnce
3837
+ isInFor
3817
3838
  ) {
3818
- // render fns generated by compiler < 2.5.4 does not provide v-once
3819
- // information to runtime so be conservative
3820
- var isOldVersion = arguments.length < 3;
3821
- // if a static tree is generated by v-once, it is cached on the instance;
3822
- // otherwise it is purely static and can be cached on the shared options
3823
- // across all instances.
3824
- var renderFns = this.$options.staticRenderFns;
3825
- var cached = isOldVersion || isOnce
3826
- ? (this._staticTrees || (this._staticTrees = []))
3827
- : (renderFns.cached || (renderFns.cached = []));
3839
+ var cached = this._staticTrees || (this._staticTrees = []);
3828
3840
  var tree = cached[index];
3829
3841
  // if has already-rendered static tree and not inside v-for,
3830
3842
  // we can reuse the same tree by doing a shallow clone.
@@ -3834,7 +3846,11 @@ function renderStatic (
3834
3846
  : cloneVNode(tree)
3835
3847
  }
3836
3848
  // otherwise, render a fresh tree.
3837
- tree = cached[index] = renderFns[index].call(this._renderProxy, null, this);
3849
+ tree = cached[index] = this.$options.staticRenderFns[index].call(
3850
+ this._renderProxy,
3851
+ null,
3852
+ this // for render fns generated for functional component templates
3853
+ );
3838
3854
  markStatic(tree, ("__static__" + index), false);
3839
3855
  return tree
3840
3856
  }
@@ -4012,6 +4028,25 @@ function mergeProps (to, from) {
4012
4028
 
4013
4029
  /* */
4014
4030
 
4031
+
4032
+
4033
+
4034
+ // Register the component hook to weex native render engine.
4035
+ // The hook will be triggered by native, not javascript.
4036
+
4037
+
4038
+ // Updates the state of the component to weex native render engine.
4039
+
4040
+ /* */
4041
+
4042
+ // https://github.com/Hanks10100/weex-native-directive/tree/master/component
4043
+
4044
+ // listening on native callback
4045
+
4046
+ /* */
4047
+
4048
+ /* */
4049
+
4015
4050
  // hooks to be invoked on component VNodes during patch
4016
4051
  var componentVNodeHooks = {
4017
4052
  init: function init (
@@ -4177,6 +4212,11 @@ function createComponent (
4177
4212
  { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children },
4178
4213
  asyncFactory
4179
4214
  );
4215
+
4216
+ // Weex specific: invoke recycle-list optimized @render function for
4217
+ // extracting cell-slot template.
4218
+ // https://github.com/Hanks10100/weex-native-directive/tree/master/component
4219
+ /* istanbul ignore if */
4180
4220
  return vnode
4181
4221
  }
4182
4222
 
@@ -4186,15 +4226,10 @@ function createComponentInstanceForVnode (
4186
4226
  parentElm,
4187
4227
  refElm
4188
4228
  ) {
4189
- var vnodeComponentOptions = vnode.componentOptions;
4190
4229
  var options = {
4191
4230
  _isComponent: true,
4192
4231
  parent: parent,
4193
- propsData: vnodeComponentOptions.propsData,
4194
- _componentTag: vnodeComponentOptions.tag,
4195
4232
  _parentVnode: vnode,
4196
- _parentListeners: vnodeComponentOptions.listeners,
4197
- _renderChildren: vnodeComponentOptions.children,
4198
4233
  _parentElm: parentElm || null,
4199
4234
  _refElm: refElm || null
4200
4235
  };
@@ -4204,7 +4239,7 @@ function createComponentInstanceForVnode (
4204
4239
  options.render = inlineTemplate.render;
4205
4240
  options.staticRenderFns = inlineTemplate.staticRenderFns;
4206
4241
  }
4207
- return new vnodeComponentOptions.Ctor(options)
4242
+ return new vnode.componentOptions.Ctor(options)
4208
4243
  }
4209
4244
 
4210
4245
  function mergeHooks (data) {
@@ -4292,11 +4327,13 @@ function _createElement (
4292
4327
  if (process.env.NODE_ENV !== 'production' &&
4293
4328
  isDef(data) && isDef(data.key) && !isPrimitive(data.key)
4294
4329
  ) {
4295
- warn(
4296
- 'Avoid using non-primitive value as key, ' +
4297
- 'use string/number value instead.',
4298
- context
4299
- );
4330
+ {
4331
+ warn(
4332
+ 'Avoid using non-primitive value as key, ' +
4333
+ 'use string/number value instead.',
4334
+ context
4335
+ );
4336
+ }
4300
4337
  }
4301
4338
  // support single function children as default scoped slot
4302
4339
  if (Array.isArray(children) &&
@@ -4538,14 +4575,18 @@ function initMixin (Vue) {
4538
4575
  function initInternalComponent (vm, options) {
4539
4576
  var opts = vm.$options = Object.create(vm.constructor.options);
4540
4577
  // doing this because it's faster than dynamic enumeration.
4578
+ var parentVnode = options._parentVnode;
4541
4579
  opts.parent = options.parent;
4542
- opts.propsData = options.propsData;
4543
- opts._parentVnode = options._parentVnode;
4544
- opts._parentListeners = options._parentListeners;
4545
- opts._renderChildren = options._renderChildren;
4546
- opts._componentTag = options._componentTag;
4580
+ opts._parentVnode = parentVnode;
4547
4581
  opts._parentElm = options._parentElm;
4548
4582
  opts._refElm = options._refElm;
4583
+
4584
+ var vnodeComponentOptions = parentVnode.componentOptions;
4585
+ opts.propsData = vnodeComponentOptions.propsData;
4586
+ opts._parentListeners = vnodeComponentOptions.listeners;
4587
+ opts._renderChildren = vnodeComponentOptions.children;
4588
+ opts._componentTag = vnodeComponentOptions.tag;
4589
+
4549
4590
  if (options.render) {
4550
4591
  opts.render = options.render;
4551
4592
  opts.staticRenderFns = options.staticRenderFns;
@@ -4679,14 +4720,8 @@ function initExtend (Vue) {
4679
4720
  }
4680
4721
 
4681
4722
  var name = extendOptions.name || Super.options.name;
4682
- if (process.env.NODE_ENV !== 'production') {
4683
- if (!/^[a-zA-Z][\w-]*$/.test(name)) {
4684
- warn(
4685
- 'Invalid component name: "' + name + '". Component names ' +
4686
- 'can only contain alphanumeric characters and the hyphen, ' +
4687
- 'and must start with a letter.'
4688
- );
4689
- }
4723
+ if (process.env.NODE_ENV !== 'production' && name) {
4724
+ validateComponentName(name);
4690
4725
  }
4691
4726
 
4692
4727
  var Sub = function VueComponent (options) {
@@ -4768,13 +4803,8 @@ function initAssetRegisters (Vue) {
4768
4803
  return this.options[type + 's'][id]
4769
4804
  } else {
4770
4805
  /* istanbul ignore if */
4771
- if (process.env.NODE_ENV !== 'production') {
4772
- if (type === 'component' && config.isReservedTag(id)) {
4773
- warn(
4774
- 'Do not use built-in or reserved HTML elements as component ' +
4775
- 'id: ' + id
4776
- );
4777
- }
4806
+ if (process.env.NODE_ENV !== 'production' && type === 'component') {
4807
+ validateComponentName(id);
4778
4808
  }
4779
4809
  if (type === 'component' && isPlainObject(definition)) {
4780
4810
  definition.name = definition.name || id;
@@ -4981,7 +5011,7 @@ Object.defineProperty(Vue$3.prototype, '$ssrContext', {
4981
5011
  }
4982
5012
  });
4983
5013
 
4984
- Vue$3.version = '2.5.9';
5014
+ Vue$3.version = '2.5.13';
4985
5015
 
4986
5016
  /* */
4987
5017
 
@@ -5033,12 +5063,12 @@ function genClassForVnode (vnode) {
5033
5063
  var childNode = vnode;
5034
5064
  while (isDef(childNode.componentInstance)) {
5035
5065
  childNode = childNode.componentInstance._vnode;
5036
- if (childNode.data) {
5066
+ if (childNode && childNode.data) {
5037
5067
  data = mergeClassData(childNode.data, data);
5038
5068
  }
5039
5069
  }
5040
5070
  while (isDef(parentNode = parentNode.parent)) {
5041
- if (parentNode.data) {
5071
+ if (parentNode && parentNode.data) {
5042
5072
  data = mergeClassData(data, parentNode.data);
5043
5073
  }
5044
5074
  }
@@ -5549,11 +5579,14 @@ function createPatchFunction (backend) {
5549
5579
 
5550
5580
  function createChildren (vnode, children, insertedVnodeQueue) {
5551
5581
  if (Array.isArray(children)) {
5582
+ if (process.env.NODE_ENV !== 'production') {
5583
+ checkDuplicateKeys(children);
5584
+ }
5552
5585
  for (var i = 0; i < children.length; ++i) {
5553
5586
  createElm(children[i], insertedVnodeQueue, vnode.elm, null, true);
5554
5587
  }
5555
5588
  } else if (isPrimitive(vnode.text)) {
5556
- nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(vnode.text));
5589
+ nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(String(vnode.text)));
5557
5590
  }
5558
5591
  }
5559
5592
 
@@ -5680,6 +5713,10 @@ function createPatchFunction (backend) {
5680
5713
  // during leaving transitions
5681
5714
  var canMove = !removeOnly;
5682
5715
 
5716
+ if (process.env.NODE_ENV !== 'production') {
5717
+ checkDuplicateKeys(newCh);
5718
+ }
5719
+
5683
5720
  while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
5684
5721
  if (isUndef(oldStartVnode)) {
5685
5722
  oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left
@@ -5712,13 +5749,6 @@ function createPatchFunction (backend) {
5712
5749
  createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm);
5713
5750
  } else {
5714
5751
  vnodeToMove = oldCh[idxInOld];
5715
- /* istanbul ignore if */
5716
- if (process.env.NODE_ENV !== 'production' && !vnodeToMove) {
5717
- warn(
5718
- 'It seems there are duplicate keys that is causing an update error. ' +
5719
- 'Make sure each v-for item has a unique key.'
5720
- );
5721
- }
5722
5752
  if (sameVnode(vnodeToMove, newStartVnode)) {
5723
5753
  patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue);
5724
5754
  oldCh[idxInOld] = undefined;
@@ -5739,6 +5769,24 @@ function createPatchFunction (backend) {
5739
5769
  }
5740
5770
  }
5741
5771
 
5772
+ function checkDuplicateKeys (children) {
5773
+ var seenKeys = {};
5774
+ for (var i = 0; i < children.length; i++) {
5775
+ var vnode = children[i];
5776
+ var key = vnode.key;
5777
+ if (isDef(key)) {
5778
+ if (seenKeys[key]) {
5779
+ warn(
5780
+ ("Duplicate keys detected: '" + key + "'. This may cause an update error."),
5781
+ vnode.context
5782
+ );
5783
+ } else {
5784
+ seenKeys[key] = true;
5785
+ }
5786
+ }
5787
+ }
5788
+ }
5789
+
5742
5790
  function findIdxInOld (node, oldCh, start, end) {
5743
5791
  for (var i = start; i < end; i++) {
5744
5792
  var c = oldCh[i];
@@ -6121,17 +6169,20 @@ function normalizeDirectives$1 (
6121
6169
  ) {
6122
6170
  var res = Object.create(null);
6123
6171
  if (!dirs) {
6172
+ // $flow-disable-line
6124
6173
  return res
6125
6174
  }
6126
6175
  var i, dir;
6127
6176
  for (i = 0; i < dirs.length; i++) {
6128
6177
  dir = dirs[i];
6129
6178
  if (!dir.modifiers) {
6179
+ // $flow-disable-line
6130
6180
  dir.modifiers = emptyModifiers;
6131
6181
  }
6132
6182
  res[getRawDirName(dir)] = dir;
6133
6183
  dir.def = resolveAsset(vm.$options, 'directives', dir.name, true);
6134
6184
  }
6185
+ // $flow-disable-line
6135
6186
  return res
6136
6187
  }
6137
6188
 
@@ -6404,10 +6455,18 @@ function pluckModuleFunction (
6404
6455
 
6405
6456
  function addProp (el, name, value) {
6406
6457
  (el.props || (el.props = [])).push({ name: name, value: value });
6458
+ el.plain = false;
6407
6459
  }
6408
6460
 
6409
6461
  function addAttr (el, name, value) {
6410
6462
  (el.attrs || (el.attrs = [])).push({ name: name, value: value });
6463
+ el.plain = false;
6464
+ }
6465
+
6466
+ // add a raw attr (use this in preTransforms)
6467
+ function addRawAttr (el, name, value) {
6468
+ el.attrsMap[name] = value;
6469
+ el.attrsList.push({ name: name, value: value });
6411
6470
  }
6412
6471
 
6413
6472
  function addDirective (
@@ -6419,6 +6478,7 @@ function addDirective (
6419
6478
  modifiers
6420
6479
  ) {
6421
6480
  (el.directives || (el.directives = [])).push({ name: name, rawName: rawName, value: value, arg: arg, modifiers: modifiers });
6481
+ el.plain = false;
6422
6482
  }
6423
6483
 
6424
6484
  function addHandler (
@@ -6491,6 +6551,8 @@ function addHandler (
6491
6551
  } else {
6492
6552
  events[name] = newHandler;
6493
6553
  }
6554
+
6555
+ el.plain = false;
6494
6556
  }
6495
6557
 
6496
6558
  function getBindingAttr (
@@ -6757,11 +6819,11 @@ function genCheckboxModel (
6757
6819
  var falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
6758
6820
  addProp(el, 'checked',
6759
6821
  "Array.isArray(" + value + ")" +
6760
- "?_i(" + value + "," + valueBinding + ")>-1" + (
6761
- trueValueBinding === 'true'
6762
- ? (":(" + value + ")")
6763
- : (":_q(" + value + "," + trueValueBinding + ")")
6764
- )
6822
+ "?_i(" + value + "," + valueBinding + ")>-1" + (
6823
+ trueValueBinding === 'true'
6824
+ ? (":(" + value + ")")
6825
+ : (":_q(" + value + "," + trueValueBinding + ")")
6826
+ )
6765
6827
  );
6766
6828
  addHandler(el, 'change',
6767
6829
  "var $$a=" + value + "," +
@@ -6778,9 +6840,9 @@ function genCheckboxModel (
6778
6840
  }
6779
6841
 
6780
6842
  function genRadioModel (
6781
- el,
6782
- value,
6783
- modifiers
6843
+ el,
6844
+ value,
6845
+ modifiers
6784
6846
  ) {
6785
6847
  var number = modifiers && modifiers.number;
6786
6848
  var valueBinding = getBindingAttr(el, 'value') || 'null';
@@ -6790,9 +6852,9 @@ function genRadioModel (
6790
6852
  }
6791
6853
 
6792
6854
  function genSelect (
6793
- el,
6794
- value,
6795
- modifiers
6855
+ el,
6856
+ value,
6857
+ modifiers
6796
6858
  ) {
6797
6859
  var number = modifiers && modifiers.number;
6798
6860
  var selectedVal = "Array.prototype.filter" +
@@ -6995,12 +7057,12 @@ function updateDOMProps (oldVnode, vnode) {
6995
7057
  function shouldUpdateValue (elm, checkVal) {
6996
7058
  return (!elm.composing && (
6997
7059
  elm.tagName === 'OPTION' ||
6998
- isDirty(elm, checkVal) ||
6999
- isInputChanged(elm, checkVal)
7060
+ isNotInFocusAndDirty(elm, checkVal) ||
7061
+ isDirtyWithModifiers(elm, checkVal)
7000
7062
  ))
7001
7063
  }
7002
7064
 
7003
- function isDirty (elm, checkVal) {
7065
+ function isNotInFocusAndDirty (elm, checkVal) {
7004
7066
  // return true when textbox (.number and .trim) loses focus and its value is
7005
7067
  // not equal to the updated value
7006
7068
  var notInFocus = true;
@@ -7010,14 +7072,20 @@ function isDirty (elm, checkVal) {
7010
7072
  return notInFocus && elm.value !== checkVal
7011
7073
  }
7012
7074
 
7013
- function isInputChanged (elm, newVal) {
7075
+ function isDirtyWithModifiers (elm, newVal) {
7014
7076
  var value = elm.value;
7015
7077
  var modifiers = elm._vModifiers; // injected by v-model runtime
7016
- if (isDef(modifiers) && modifiers.number) {
7017
- return toNumber(value) !== toNumber(newVal)
7018
- }
7019
- if (isDef(modifiers) && modifiers.trim) {
7020
- return value.trim() !== newVal.trim()
7078
+ if (isDef(modifiers)) {
7079
+ if (modifiers.lazy) {
7080
+ // inputs with lazy should only be updated when not in focus
7081
+ return false
7082
+ }
7083
+ if (modifiers.number) {
7084
+ return toNumber(value) !== toNumber(newVal)
7085
+ }
7086
+ if (modifiers.trim) {
7087
+ return value.trim() !== newVal.trim()
7088
+ }
7021
7089
  }
7022
7090
  return value !== newVal
7023
7091
  }
@@ -7075,7 +7143,10 @@ function getStyle (vnode, checkChild) {
7075
7143
  var childNode = vnode;
7076
7144
  while (childNode.componentInstance) {
7077
7145
  childNode = childNode.componentInstance._vnode;
7078
- if (childNode.data && (styleData = normalizeStyleData(childNode.data))) {
7146
+ if (
7147
+ childNode && childNode.data &&
7148
+ (styleData = normalizeStyleData(childNode.data))
7149
+ ) {
7079
7150
  extend(res, styleData);
7080
7151
  }
7081
7152
  }
@@ -8231,7 +8302,7 @@ var TransitionGroup = {
8231
8302
  this._vnode,
8232
8303
  this.kept,
8233
8304
  false, // hydrating
8234
- true // removeOnly (!important, avoids unnecessary moves)
8305
+ true // removeOnly (!important avoids unnecessary moves)
8235
8306
  );
8236
8307
  this._vnode = this.kept;
8237
8308
  },
@@ -8394,6 +8465,8 @@ var buildRegex = cached(function (delimiters) {
8394
8465
  return new RegExp(open + '((?:.|\\n)+?)' + close, 'g')
8395
8466
  });
8396
8467
 
8468
+
8469
+
8397
8470
  function parseText (
8398
8471
  text,
8399
8472
  delimiters
@@ -8403,23 +8476,30 @@ function parseText (
8403
8476
  return
8404
8477
  }
8405
8478
  var tokens = [];
8479
+ var rawTokens = [];
8406
8480
  var lastIndex = tagRE.lastIndex = 0;
8407
- var match, index;
8481
+ var match, index, tokenValue;
8408
8482
  while ((match = tagRE.exec(text))) {
8409
8483
  index = match.index;
8410
8484
  // push text token
8411
8485
  if (index > lastIndex) {
8412
- tokens.push(JSON.stringify(text.slice(lastIndex, index)));
8486
+ rawTokens.push(tokenValue = text.slice(lastIndex, index));
8487
+ tokens.push(JSON.stringify(tokenValue));
8413
8488
  }
8414
8489
  // tag token
8415
8490
  var exp = parseFilters(match[1].trim());
8416
8491
  tokens.push(("_s(" + exp + ")"));
8492
+ rawTokens.push({ '@binding': exp });
8417
8493
  lastIndex = index + match[0].length;
8418
8494
  }
8419
8495
  if (lastIndex < text.length) {
8420
- tokens.push(JSON.stringify(text.slice(lastIndex)));
8496
+ rawTokens.push(tokenValue = text.slice(lastIndex));
8497
+ tokens.push(JSON.stringify(tokenValue));
8498
+ }
8499
+ return {
8500
+ expression: tokens.join('+'),
8501
+ tokens: rawTokens
8421
8502
  }
8422
- return tokens.join('+')
8423
8503
  }
8424
8504
 
8425
8505
  /* */
@@ -8428,8 +8508,8 @@ function transformNode (el, options) {
8428
8508
  var warn = options.warn || baseWarn;
8429
8509
  var staticClass = getAndRemoveAttr(el, 'class');
8430
8510
  if (process.env.NODE_ENV !== 'production' && staticClass) {
8431
- var expression = parseText(staticClass, options.delimiters);
8432
- if (expression) {
8511
+ var res = parseText(staticClass, options.delimiters);
8512
+ if (res) {
8433
8513
  warn(
8434
8514
  "class=\"" + staticClass + "\": " +
8435
8515
  'Interpolation inside attributes has been removed. ' +
@@ -8472,8 +8552,8 @@ function transformNode$1 (el, options) {
8472
8552
  if (staticStyle) {
8473
8553
  /* istanbul ignore if */
8474
8554
  if (process.env.NODE_ENV !== 'production') {
8475
- var expression = parseText(staticStyle, options.delimiters);
8476
- if (expression) {
8555
+ var res = parseText(staticStyle, options.delimiters);
8556
+ if (res) {
8477
8557
  warn(
8478
8558
  "style=\"" + staticStyle + "\": " +
8479
8559
  'Interpolation inside attributes has been removed. ' +
@@ -8855,7 +8935,7 @@ function parseHTML (html, options) {
8855
8935
  var onRE = /^@|^v-on:/;
8856
8936
  var dirRE = /^v-|^@|^:/;
8857
8937
  var forAliasRE = /(.*?)\s+(?:in|of)\s+(.*)/;
8858
- var forIteratorRE = /\((\{[^}]*\}|[^,{]*),([^,]*)(?:,([^,]*))?\)/;
8938
+ var forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
8859
8939
  var stripParensRE = /^\(|\)$/g;
8860
8940
 
8861
8941
  var argRE = /:(.*)$/;
@@ -8925,7 +9005,7 @@ function parse (
8925
9005
  }
8926
9006
  }
8927
9007
 
8928
- function endPre (element) {
9008
+ function closeElement (element) {
8929
9009
  // check pre state
8930
9010
  if (element.pre) {
8931
9011
  inVPre = false;
@@ -8933,6 +9013,10 @@ function parse (
8933
9013
  if (platformIsPreTag(element.tag)) {
8934
9014
  inPre = false;
8935
9015
  }
9016
+ // apply post-transforms
9017
+ for (var i = 0; i < postTransforms.length; i++) {
9018
+ postTransforms[i](element, options);
9019
+ }
8936
9020
  }
8937
9021
 
8938
9022
  parseHTML(template, {
@@ -9045,11 +9129,7 @@ function parse (
9045
9129
  currentParent = element;
9046
9130
  stack.push(element);
9047
9131
  } else {
9048
- endPre(element);
9049
- }
9050
- // apply post-transforms
9051
- for (var i$1 = 0; i$1 < postTransforms.length; i$1++) {
9052
- postTransforms[i$1](element, options);
9132
+ closeElement(element);
9053
9133
  }
9054
9134
  },
9055
9135
 
@@ -9063,7 +9143,7 @@ function parse (
9063
9143
  // pop stack
9064
9144
  stack.length -= 1;
9065
9145
  currentParent = stack[stack.length - 1];
9066
- endPre(element);
9146
+ closeElement(element);
9067
9147
  },
9068
9148
 
9069
9149
  chars: function chars (text) {
@@ -9095,11 +9175,12 @@ function parse (
9095
9175
  // only preserve whitespace if its not right after a starting tag
9096
9176
  : preserveWhitespace && children.length ? ' ' : '';
9097
9177
  if (text) {
9098
- var expression;
9099
- if (!inVPre && text !== ' ' && (expression = parseText(text, delimiters))) {
9178
+ var res;
9179
+ if (!inVPre && text !== ' ' && (res = parseText(text, delimiters))) {
9100
9180
  children.push({
9101
9181
  type: 2,
9102
- expression: expression,
9182
+ expression: res.expression,
9183
+ tokens: res.tokens,
9103
9184
  text: text
9104
9185
  });
9105
9186
  } else if (text !== ' ' || !children.length || children[children.length - 1].text !== ' ') {
@@ -9180,26 +9261,34 @@ function processRef (el) {
9180
9261
  function processFor (el) {
9181
9262
  var exp;
9182
9263
  if ((exp = getAndRemoveAttr(el, 'v-for'))) {
9183
- var inMatch = exp.match(forAliasRE);
9184
- if (!inMatch) {
9185
- process.env.NODE_ENV !== 'production' && warn$2(
9264
+ var res = parseFor(exp);
9265
+ if (res) {
9266
+ extend(el, res);
9267
+ } else if (process.env.NODE_ENV !== 'production') {
9268
+ warn$2(
9186
9269
  ("Invalid v-for expression: " + exp)
9187
9270
  );
9188
- return
9189
9271
  }
9190
- el.for = inMatch[2].trim();
9191
- var alias = inMatch[1].trim();
9192
- var iteratorMatch = alias.match(forIteratorRE);
9193
- if (iteratorMatch) {
9194
- el.alias = iteratorMatch[1].trim();
9195
- el.iterator1 = iteratorMatch[2].trim();
9196
- if (iteratorMatch[3]) {
9197
- el.iterator2 = iteratorMatch[3].trim();
9198
- }
9199
- } else {
9200
- el.alias = alias.replace(stripParensRE, '');
9272
+ }
9273
+ }
9274
+
9275
+ function parseFor (exp) {
9276
+ var inMatch = exp.match(forAliasRE);
9277
+ if (!inMatch) { return }
9278
+ var res = {};
9279
+ res.for = inMatch[2].trim();
9280
+ var alias = inMatch[1].trim().replace(stripParensRE, '');
9281
+ var iteratorMatch = alias.match(forIteratorRE);
9282
+ if (iteratorMatch) {
9283
+ res.alias = alias.replace(forIteratorRE, '');
9284
+ res.iterator1 = iteratorMatch[1].trim();
9285
+ if (iteratorMatch[2]) {
9286
+ res.iterator2 = iteratorMatch[2].trim();
9201
9287
  }
9288
+ } else {
9289
+ res.alias = alias;
9202
9290
  }
9291
+ return res
9203
9292
  }
9204
9293
 
9205
9294
  function processIf (el) {
@@ -9387,8 +9476,8 @@ function processAttrs (el) {
9387
9476
  } else {
9388
9477
  // literal attribute
9389
9478
  if (process.env.NODE_ENV !== 'production') {
9390
- var expression = parseText(value, delimiters);
9391
- if (expression) {
9479
+ var res = parseText(value, delimiters);
9480
+ if (res) {
9392
9481
  warn$2(
9393
9482
  name + "=\"" + value + "\": " +
9394
9483
  'Interpolation inside attributes has been removed. ' +
@@ -9557,11 +9646,6 @@ function cloneASTElement (el) {
9557
9646
  return createASTElement(el.tag, el.attrsList.slice(), el.parent)
9558
9647
  }
9559
9648
 
9560
- function addRawAttr (el, name, value) {
9561
- el.attrsMap[name] = value;
9562
- el.attrsList.push({ name: name, value: value });
9563
- }
9564
-
9565
9649
  var model$2 = {
9566
9650
  preTransformNode: preTransformNode
9567
9651
  };
@@ -9800,9 +9884,11 @@ function genHandler (
9800
9884
  var isFunctionExpression = fnExpRE.test(handler.value);
9801
9885
 
9802
9886
  if (!handler.modifiers) {
9803
- return isMethodPath || isFunctionExpression
9804
- ? handler.value
9805
- : ("function($event){" + (handler.value) + "}") // inline statement
9887
+ if (isMethodPath || isFunctionExpression) {
9888
+ return handler.value
9889
+ }
9890
+ /* istanbul ignore if */
9891
+ return ("function($event){" + (handler.value) + "}") // inline statement
9806
9892
  } else {
9807
9893
  var code = '';
9808
9894
  var genModifierCode = '';
@@ -9838,6 +9924,7 @@ function genHandler (
9838
9924
  : isFunctionExpression
9839
9925
  ? ("(" + (handler.value) + ")($event)")
9840
9926
  : handler.value;
9927
+ /* istanbul ignore if */
9841
9928
  return ("function($event){" + code + handlerCode + "}")
9842
9929
  }
9843
9930
  }
@@ -9946,10 +10033,10 @@ function genElement (el, state) {
9946
10033
  }
9947
10034
 
9948
10035
  // hoist static sub-trees out
9949
- function genStatic (el, state, once$$1) {
10036
+ function genStatic (el, state) {
9950
10037
  el.staticProcessed = true;
9951
10038
  state.staticRenderFns.push(("with(this){return " + (genElement(el, state)) + "}"));
9952
- return ("_m(" + (state.staticRenderFns.length - 1) + "," + (el.staticInFor ? 'true' : 'false') + "," + (once$$1 ? 'true' : 'false') + ")")
10039
+ return ("_m(" + (state.staticRenderFns.length - 1) + (el.staticInFor ? ',true' : '') + ")")
9953
10040
  }
9954
10041
 
9955
10042
  // v-once
@@ -9975,7 +10062,7 @@ function genOnce (el, state) {
9975
10062
  }
9976
10063
  return ("_o(" + (genElement(el, state)) + "," + (state.onceId++) + "," + key + ")")
9977
10064
  } else {
9978
- return genStatic(el, state, true)
10065
+ return genStatic(el, state)
9979
10066
  }
9980
10067
  }
9981
10068
 
@@ -10315,7 +10402,10 @@ function genProps (props) {
10315
10402
  var res = '';
10316
10403
  for (var i = 0; i < props.length; i++) {
10317
10404
  var prop = props[i];
10318
- res += "\"" + (prop.name) + "\":" + (transformSpecialNewlines(prop.value)) + ",";
10405
+ /* istanbul ignore if */
10406
+ {
10407
+ res += "\"" + (prop.name) + "\":" + (transformSpecialNewlines(prop.value)) + ",";
10408
+ }
10319
10409
  }
10320
10410
  return res.slice(0, -1)
10321
10411
  }
@@ -10555,7 +10645,7 @@ function createCompilerCreator (baseCompile) {
10555
10645
  // merge custom directives
10556
10646
  if (options.directives) {
10557
10647
  finalOptions.directives = extend(
10558
- Object.create(baseOptions.directives),
10648
+ Object.create(baseOptions.directives || null),
10559
10649
  options.directives
10560
10650
  );
10561
10651
  }
@@ -10593,7 +10683,9 @@ var createCompiler = createCompilerCreator(function baseCompile (
10593
10683
  options
10594
10684
  ) {
10595
10685
  var ast = parse(template.trim(), options);
10596
- optimize(ast, options);
10686
+ if (options.optimize !== false) {
10687
+ optimize(ast, options);
10688
+ }
10597
10689
  var code = generate(ast, options);
10598
10690
  return {
10599
10691
  ast: ast,