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
@@ -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
  */
@@ -34,6 +34,8 @@ function isPrimitive (value) {
34
34
  return (
35
35
  typeof value === 'string' ||
36
36
  typeof value === 'number' ||
37
+ // $flow-disable-line
38
+ typeof value === 'symbol' ||
37
39
  typeof value === 'boolean'
38
40
  )
39
41
  }
@@ -342,6 +344,7 @@ var config = ({
342
344
  /**
343
345
  * Option merge strategies (used in core/util/options)
344
346
  */
347
+ // $flow-disable-line
345
348
  optionMergeStrategies: Object.create(null),
346
349
 
347
350
  /**
@@ -382,6 +385,7 @@ var config = ({
382
385
  /**
383
386
  * Custom user key aliases for v-on
384
387
  */
388
+ // $flow-disable-line
385
389
  keyCodes: Object.create(null),
386
390
 
387
391
  /**
@@ -816,8 +820,7 @@ var arrayMethods = Object.create(arrayProto);[
816
820
  'splice',
817
821
  'sort',
818
822
  'reverse'
819
- ]
820
- .forEach(function (method) {
823
+ ].forEach(function (method) {
821
824
  // cache original method
822
825
  var original = arrayProto[method];
823
826
  def(arrayMethods, method, function mutator () {
@@ -1149,18 +1152,18 @@ function mergeDataOrFn (
1149
1152
  // it has to be a function to pass previous merges.
1150
1153
  return function mergedDataFn () {
1151
1154
  return mergeData(
1152
- typeof childVal === 'function' ? childVal.call(this) : childVal,
1153
- typeof parentVal === 'function' ? parentVal.call(this) : parentVal
1155
+ typeof childVal === 'function' ? childVal.call(this, this) : childVal,
1156
+ typeof parentVal === 'function' ? parentVal.call(this, this) : parentVal
1154
1157
  )
1155
1158
  }
1156
1159
  } else {
1157
1160
  return function mergedInstanceDataFn () {
1158
1161
  // instance merge
1159
1162
  var instanceData = typeof childVal === 'function'
1160
- ? childVal.call(vm)
1163
+ ? childVal.call(vm, vm)
1161
1164
  : childVal;
1162
1165
  var defaultData = typeof parentVal === 'function'
1163
- ? parentVal.call(vm)
1166
+ ? parentVal.call(vm, vm)
1164
1167
  : parentVal;
1165
1168
  if (instanceData) {
1166
1169
  return mergeData(instanceData, defaultData)
@@ -1312,13 +1315,23 @@ var defaultStrat = function (parentVal, childVal) {
1312
1315
  */
1313
1316
  function checkComponents (options) {
1314
1317
  for (var key in options.components) {
1315
- var lower = key.toLowerCase();
1316
- if (isBuiltInTag(lower) || config.isReservedTag(lower)) {
1317
- warn(
1318
- 'Do not use built-in or reserved HTML elements as component ' +
1319
- 'id: ' + key
1320
- );
1321
- }
1318
+ validateComponentName(key);
1319
+ }
1320
+ }
1321
+
1322
+ function validateComponentName (name) {
1323
+ if (!/^[a-zA-Z][\w-]*$/.test(name)) {
1324
+ warn(
1325
+ 'Invalid component name: "' + name + '". Component names ' +
1326
+ 'can only contain alphanumeric characters and the hyphen, ' +
1327
+ 'and must start with a letter.'
1328
+ );
1329
+ }
1330
+ if (isBuiltInTag(name) || config.isReservedTag(name)) {
1331
+ warn(
1332
+ 'Do not use built-in or reserved HTML elements as component ' +
1333
+ 'id: ' + name
1334
+ );
1322
1335
  }
1323
1336
  }
1324
1337
 
@@ -1365,6 +1378,7 @@ function normalizeProps (options, vm) {
1365
1378
  */
1366
1379
  function normalizeInject (options, vm) {
1367
1380
  var inject = options.inject;
1381
+ if (!inject) { return }
1368
1382
  var normalized = options.inject = {};
1369
1383
  if (Array.isArray(inject)) {
1370
1384
  for (var i = 0; i < inject.length; i++) {
@@ -1377,7 +1391,7 @@ function normalizeInject (options, vm) {
1377
1391
  ? extend({ from: key }, val)
1378
1392
  : { from: val };
1379
1393
  }
1380
- } else if (process.env.NODE_ENV !== 'production' && inject) {
1394
+ } else if (process.env.NODE_ENV !== 'production') {
1381
1395
  warn(
1382
1396
  "Invalid value for option \"inject\": expected an Array or an Object, " +
1383
1397
  "but got " + (toRawType(inject)) + ".",
@@ -1519,7 +1533,11 @@ function validateProp (
1519
1533
  observe(value);
1520
1534
  observerState.shouldConvert = prevShouldConvert;
1521
1535
  }
1522
- if (process.env.NODE_ENV !== 'production') {
1536
+ if (
1537
+ process.env.NODE_ENV !== 'production' &&
1538
+ // skip validation for weex recycle-list child component props
1539
+ !(false && isObject(value) && ('@binding' in value))
1540
+ ) {
1523
1541
  assertProp(prop, key, value, vm, absent);
1524
1542
  }
1525
1543
  return value
@@ -1999,11 +2017,12 @@ function updateListeners (
1999
2017
  remove$$1,
2000
2018
  vm
2001
2019
  ) {
2002
- var name, cur, old, event;
2020
+ var name, def, cur, old, event;
2003
2021
  for (name in on) {
2004
- cur = on[name];
2022
+ def = cur = on[name];
2005
2023
  old = oldOn[name];
2006
2024
  event = normalizeEvent(name);
2025
+ /* istanbul ignore if */
2007
2026
  if (isUndef(cur)) {
2008
2027
  process.env.NODE_ENV !== 'production' && warn(
2009
2028
  "Invalid handler for event \"" + (event.name) + "\": got " + String(cur),
@@ -2013,7 +2032,7 @@ function updateListeners (
2013
2032
  if (isUndef(cur.fns)) {
2014
2033
  cur = on[name] = createFnInvoker(cur);
2015
2034
  }
2016
- add(event.name, cur, event.once, event.capture, event.passive);
2035
+ add(event.name, cur, event.once, event.capture, event.passive, event.params);
2017
2036
  } else if (cur !== old) {
2018
2037
  old.fns = cur;
2019
2038
  on[name] = old;
@@ -2507,6 +2526,8 @@ function eventsMixin (Vue) {
2507
2526
 
2508
2527
  /* */
2509
2528
 
2529
+
2530
+
2510
2531
  /**
2511
2532
  * Runtime helper for resolving raw children VNodes into a slot object.
2512
2533
  */
@@ -2530,10 +2551,10 @@ function resolveSlots (
2530
2551
  if ((child.context === context || child.fnContext === context) &&
2531
2552
  data && data.slot != null
2532
2553
  ) {
2533
- var name = child.data.slot;
2554
+ var name = data.slot;
2534
2555
  var slot = (slots[name] || (slots[name] = []));
2535
2556
  if (child.tag === 'template') {
2536
- slot.push.apply(slot, child.children);
2557
+ slot.push.apply(slot, child.children || []);
2537
2558
  } else {
2538
2559
  slot.push(child);
2539
2560
  }
@@ -3374,6 +3395,7 @@ function getData (data, vm) {
3374
3395
  var computedWatcherOptions = { lazy: true };
3375
3396
 
3376
3397
  function initComputed (vm, computed) {
3398
+ // $flow-disable-line
3377
3399
  var watchers = vm._computedWatchers = Object.create(null);
3378
3400
  // computed properties are just getters during SSR
3379
3401
  var isSSR = isServerRendering();
@@ -3604,11 +3626,11 @@ function resolveInject (inject, vm) {
3604
3626
  // inject is :any because flow is not smart enough to figure out cached
3605
3627
  var result = Object.create(null);
3606
3628
  var keys = hasSymbol
3607
- ? Reflect.ownKeys(inject).filter(function (key) {
3608
- /* istanbul ignore next */
3609
- return Object.getOwnPropertyDescriptor(inject, key).enumerable
3610
- })
3611
- : Object.keys(inject);
3629
+ ? Reflect.ownKeys(inject).filter(function (key) {
3630
+ /* istanbul ignore next */
3631
+ return Object.getOwnPropertyDescriptor(inject, key).enumerable
3632
+ })
3633
+ : Object.keys(inject);
3612
3634
 
3613
3635
  for (var i = 0; i < keys.length; i++) {
3614
3636
  var key = keys[i];
@@ -3814,19 +3836,9 @@ function bindObjectProps (
3814
3836
  */
3815
3837
  function renderStatic (
3816
3838
  index,
3817
- isInFor,
3818
- isOnce
3839
+ isInFor
3819
3840
  ) {
3820
- // render fns generated by compiler < 2.5.4 does not provide v-once
3821
- // information to runtime so be conservative
3822
- var isOldVersion = arguments.length < 3;
3823
- // if a static tree is generated by v-once, it is cached on the instance;
3824
- // otherwise it is purely static and can be cached on the shared options
3825
- // across all instances.
3826
- var renderFns = this.$options.staticRenderFns;
3827
- var cached = isOldVersion || isOnce
3828
- ? (this._staticTrees || (this._staticTrees = []))
3829
- : (renderFns.cached || (renderFns.cached = []));
3841
+ var cached = this._staticTrees || (this._staticTrees = []);
3830
3842
  var tree = cached[index];
3831
3843
  // if has already-rendered static tree and not inside v-for,
3832
3844
  // we can reuse the same tree by doing a shallow clone.
@@ -3836,7 +3848,11 @@ function renderStatic (
3836
3848
  : cloneVNode(tree)
3837
3849
  }
3838
3850
  // otherwise, render a fresh tree.
3839
- tree = cached[index] = renderFns[index].call(this._renderProxy, null, this);
3851
+ tree = cached[index] = this.$options.staticRenderFns[index].call(
3852
+ this._renderProxy,
3853
+ null,
3854
+ this // for render fns generated for functional component templates
3855
+ );
3840
3856
  markStatic(tree, ("__static__" + index), false);
3841
3857
  return tree
3842
3858
  }
@@ -4014,6 +4030,25 @@ function mergeProps (to, from) {
4014
4030
 
4015
4031
  /* */
4016
4032
 
4033
+
4034
+
4035
+
4036
+ // Register the component hook to weex native render engine.
4037
+ // The hook will be triggered by native, not javascript.
4038
+
4039
+
4040
+ // Updates the state of the component to weex native render engine.
4041
+
4042
+ /* */
4043
+
4044
+ // https://github.com/Hanks10100/weex-native-directive/tree/master/component
4045
+
4046
+ // listening on native callback
4047
+
4048
+ /* */
4049
+
4050
+ /* */
4051
+
4017
4052
  // hooks to be invoked on component VNodes during patch
4018
4053
  var componentVNodeHooks = {
4019
4054
  init: function init (
@@ -4179,6 +4214,11 @@ function createComponent (
4179
4214
  { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children },
4180
4215
  asyncFactory
4181
4216
  );
4217
+
4218
+ // Weex specific: invoke recycle-list optimized @render function for
4219
+ // extracting cell-slot template.
4220
+ // https://github.com/Hanks10100/weex-native-directive/tree/master/component
4221
+ /* istanbul ignore if */
4182
4222
  return vnode
4183
4223
  }
4184
4224
 
@@ -4188,15 +4228,10 @@ function createComponentInstanceForVnode (
4188
4228
  parentElm,
4189
4229
  refElm
4190
4230
  ) {
4191
- var vnodeComponentOptions = vnode.componentOptions;
4192
4231
  var options = {
4193
4232
  _isComponent: true,
4194
4233
  parent: parent,
4195
- propsData: vnodeComponentOptions.propsData,
4196
- _componentTag: vnodeComponentOptions.tag,
4197
4234
  _parentVnode: vnode,
4198
- _parentListeners: vnodeComponentOptions.listeners,
4199
- _renderChildren: vnodeComponentOptions.children,
4200
4235
  _parentElm: parentElm || null,
4201
4236
  _refElm: refElm || null
4202
4237
  };
@@ -4206,7 +4241,7 @@ function createComponentInstanceForVnode (
4206
4241
  options.render = inlineTemplate.render;
4207
4242
  options.staticRenderFns = inlineTemplate.staticRenderFns;
4208
4243
  }
4209
- return new vnodeComponentOptions.Ctor(options)
4244
+ return new vnode.componentOptions.Ctor(options)
4210
4245
  }
4211
4246
 
4212
4247
  function mergeHooks (data) {
@@ -4294,11 +4329,13 @@ function _createElement (
4294
4329
  if (process.env.NODE_ENV !== 'production' &&
4295
4330
  isDef(data) && isDef(data.key) && !isPrimitive(data.key)
4296
4331
  ) {
4297
- warn(
4298
- 'Avoid using non-primitive value as key, ' +
4299
- 'use string/number value instead.',
4300
- context
4301
- );
4332
+ {
4333
+ warn(
4334
+ 'Avoid using non-primitive value as key, ' +
4335
+ 'use string/number value instead.',
4336
+ context
4337
+ );
4338
+ }
4302
4339
  }
4303
4340
  // support single function children as default scoped slot
4304
4341
  if (Array.isArray(children) &&
@@ -4540,14 +4577,18 @@ function initMixin (Vue) {
4540
4577
  function initInternalComponent (vm, options) {
4541
4578
  var opts = vm.$options = Object.create(vm.constructor.options);
4542
4579
  // doing this because it's faster than dynamic enumeration.
4580
+ var parentVnode = options._parentVnode;
4543
4581
  opts.parent = options.parent;
4544
- opts.propsData = options.propsData;
4545
- opts._parentVnode = options._parentVnode;
4546
- opts._parentListeners = options._parentListeners;
4547
- opts._renderChildren = options._renderChildren;
4548
- opts._componentTag = options._componentTag;
4582
+ opts._parentVnode = parentVnode;
4549
4583
  opts._parentElm = options._parentElm;
4550
4584
  opts._refElm = options._refElm;
4585
+
4586
+ var vnodeComponentOptions = parentVnode.componentOptions;
4587
+ opts.propsData = vnodeComponentOptions.propsData;
4588
+ opts._parentListeners = vnodeComponentOptions.listeners;
4589
+ opts._renderChildren = vnodeComponentOptions.children;
4590
+ opts._componentTag = vnodeComponentOptions.tag;
4591
+
4551
4592
  if (options.render) {
4552
4593
  opts.render = options.render;
4553
4594
  opts.staticRenderFns = options.staticRenderFns;
@@ -4681,14 +4722,8 @@ function initExtend (Vue) {
4681
4722
  }
4682
4723
 
4683
4724
  var name = extendOptions.name || Super.options.name;
4684
- if (process.env.NODE_ENV !== 'production') {
4685
- if (!/^[a-zA-Z][\w-]*$/.test(name)) {
4686
- warn(
4687
- 'Invalid component name: "' + name + '". Component names ' +
4688
- 'can only contain alphanumeric characters and the hyphen, ' +
4689
- 'and must start with a letter.'
4690
- );
4691
- }
4725
+ if (process.env.NODE_ENV !== 'production' && name) {
4726
+ validateComponentName(name);
4692
4727
  }
4693
4728
 
4694
4729
  var Sub = function VueComponent (options) {
@@ -4770,13 +4805,8 @@ function initAssetRegisters (Vue) {
4770
4805
  return this.options[type + 's'][id]
4771
4806
  } else {
4772
4807
  /* istanbul ignore if */
4773
- if (process.env.NODE_ENV !== 'production') {
4774
- if (type === 'component' && config.isReservedTag(id)) {
4775
- warn(
4776
- 'Do not use built-in or reserved HTML elements as component ' +
4777
- 'id: ' + id
4778
- );
4779
- }
4808
+ if (process.env.NODE_ENV !== 'production' && type === 'component') {
4809
+ validateComponentName(id);
4780
4810
  }
4781
4811
  if (type === 'component' && isPlainObject(definition)) {
4782
4812
  definition.name = definition.name || id;
@@ -4983,7 +5013,7 @@ Object.defineProperty(Vue$3.prototype, '$ssrContext', {
4983
5013
  }
4984
5014
  });
4985
5015
 
4986
- Vue$3.version = '2.5.9';
5016
+ Vue$3.version = '2.5.13';
4987
5017
 
4988
5018
  /* */
4989
5019
 
@@ -5035,12 +5065,12 @@ function genClassForVnode (vnode) {
5035
5065
  var childNode = vnode;
5036
5066
  while (isDef(childNode.componentInstance)) {
5037
5067
  childNode = childNode.componentInstance._vnode;
5038
- if (childNode.data) {
5068
+ if (childNode && childNode.data) {
5039
5069
  data = mergeClassData(childNode.data, data);
5040
5070
  }
5041
5071
  }
5042
5072
  while (isDef(parentNode = parentNode.parent)) {
5043
- if (parentNode.data) {
5073
+ if (parentNode && parentNode.data) {
5044
5074
  data = mergeClassData(data, parentNode.data);
5045
5075
  }
5046
5076
  }
@@ -5551,11 +5581,14 @@ function createPatchFunction (backend) {
5551
5581
 
5552
5582
  function createChildren (vnode, children, insertedVnodeQueue) {
5553
5583
  if (Array.isArray(children)) {
5584
+ if (process.env.NODE_ENV !== 'production') {
5585
+ checkDuplicateKeys(children);
5586
+ }
5554
5587
  for (var i = 0; i < children.length; ++i) {
5555
5588
  createElm(children[i], insertedVnodeQueue, vnode.elm, null, true);
5556
5589
  }
5557
5590
  } else if (isPrimitive(vnode.text)) {
5558
- nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(vnode.text));
5591
+ nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(String(vnode.text)));
5559
5592
  }
5560
5593
  }
5561
5594
 
@@ -5682,6 +5715,10 @@ function createPatchFunction (backend) {
5682
5715
  // during leaving transitions
5683
5716
  var canMove = !removeOnly;
5684
5717
 
5718
+ if (process.env.NODE_ENV !== 'production') {
5719
+ checkDuplicateKeys(newCh);
5720
+ }
5721
+
5685
5722
  while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
5686
5723
  if (isUndef(oldStartVnode)) {
5687
5724
  oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left
@@ -5714,13 +5751,6 @@ function createPatchFunction (backend) {
5714
5751
  createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm);
5715
5752
  } else {
5716
5753
  vnodeToMove = oldCh[idxInOld];
5717
- /* istanbul ignore if */
5718
- if (process.env.NODE_ENV !== 'production' && !vnodeToMove) {
5719
- warn(
5720
- 'It seems there are duplicate keys that is causing an update error. ' +
5721
- 'Make sure each v-for item has a unique key.'
5722
- );
5723
- }
5724
5754
  if (sameVnode(vnodeToMove, newStartVnode)) {
5725
5755
  patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue);
5726
5756
  oldCh[idxInOld] = undefined;
@@ -5741,6 +5771,24 @@ function createPatchFunction (backend) {
5741
5771
  }
5742
5772
  }
5743
5773
 
5774
+ function checkDuplicateKeys (children) {
5775
+ var seenKeys = {};
5776
+ for (var i = 0; i < children.length; i++) {
5777
+ var vnode = children[i];
5778
+ var key = vnode.key;
5779
+ if (isDef(key)) {
5780
+ if (seenKeys[key]) {
5781
+ warn(
5782
+ ("Duplicate keys detected: '" + key + "'. This may cause an update error."),
5783
+ vnode.context
5784
+ );
5785
+ } else {
5786
+ seenKeys[key] = true;
5787
+ }
5788
+ }
5789
+ }
5790
+ }
5791
+
5744
5792
  function findIdxInOld (node, oldCh, start, end) {
5745
5793
  for (var i = start; i < end; i++) {
5746
5794
  var c = oldCh[i];
@@ -6123,17 +6171,20 @@ function normalizeDirectives$1 (
6123
6171
  ) {
6124
6172
  var res = Object.create(null);
6125
6173
  if (!dirs) {
6174
+ // $flow-disable-line
6126
6175
  return res
6127
6176
  }
6128
6177
  var i, dir;
6129
6178
  for (i = 0; i < dirs.length; i++) {
6130
6179
  dir = dirs[i];
6131
6180
  if (!dir.modifiers) {
6181
+ // $flow-disable-line
6132
6182
  dir.modifiers = emptyModifiers;
6133
6183
  }
6134
6184
  res[getRawDirName(dir)] = dir;
6135
6185
  dir.def = resolveAsset(vm.$options, 'directives', dir.name, true);
6136
6186
  }
6187
+ // $flow-disable-line
6137
6188
  return res
6138
6189
  }
6139
6190
 
@@ -6406,10 +6457,18 @@ function pluckModuleFunction (
6406
6457
 
6407
6458
  function addProp (el, name, value) {
6408
6459
  (el.props || (el.props = [])).push({ name: name, value: value });
6460
+ el.plain = false;
6409
6461
  }
6410
6462
 
6411
6463
  function addAttr (el, name, value) {
6412
6464
  (el.attrs || (el.attrs = [])).push({ name: name, value: value });
6465
+ el.plain = false;
6466
+ }
6467
+
6468
+ // add a raw attr (use this in preTransforms)
6469
+ function addRawAttr (el, name, value) {
6470
+ el.attrsMap[name] = value;
6471
+ el.attrsList.push({ name: name, value: value });
6413
6472
  }
6414
6473
 
6415
6474
  function addDirective (
@@ -6421,6 +6480,7 @@ function addDirective (
6421
6480
  modifiers
6422
6481
  ) {
6423
6482
  (el.directives || (el.directives = [])).push({ name: name, rawName: rawName, value: value, arg: arg, modifiers: modifiers });
6483
+ el.plain = false;
6424
6484
  }
6425
6485
 
6426
6486
  function addHandler (
@@ -6493,6 +6553,8 @@ function addHandler (
6493
6553
  } else {
6494
6554
  events[name] = newHandler;
6495
6555
  }
6556
+
6557
+ el.plain = false;
6496
6558
  }
6497
6559
 
6498
6560
  function getBindingAttr (
@@ -6759,11 +6821,11 @@ function genCheckboxModel (
6759
6821
  var falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
6760
6822
  addProp(el, 'checked',
6761
6823
  "Array.isArray(" + value + ")" +
6762
- "?_i(" + value + "," + valueBinding + ")>-1" + (
6763
- trueValueBinding === 'true'
6764
- ? (":(" + value + ")")
6765
- : (":_q(" + value + "," + trueValueBinding + ")")
6766
- )
6824
+ "?_i(" + value + "," + valueBinding + ")>-1" + (
6825
+ trueValueBinding === 'true'
6826
+ ? (":(" + value + ")")
6827
+ : (":_q(" + value + "," + trueValueBinding + ")")
6828
+ )
6767
6829
  );
6768
6830
  addHandler(el, 'change',
6769
6831
  "var $$a=" + value + "," +
@@ -6780,9 +6842,9 @@ function genCheckboxModel (
6780
6842
  }
6781
6843
 
6782
6844
  function genRadioModel (
6783
- el,
6784
- value,
6785
- modifiers
6845
+ el,
6846
+ value,
6847
+ modifiers
6786
6848
  ) {
6787
6849
  var number = modifiers && modifiers.number;
6788
6850
  var valueBinding = getBindingAttr(el, 'value') || 'null';
@@ -6792,9 +6854,9 @@ function genRadioModel (
6792
6854
  }
6793
6855
 
6794
6856
  function genSelect (
6795
- el,
6796
- value,
6797
- modifiers
6857
+ el,
6858
+ value,
6859
+ modifiers
6798
6860
  ) {
6799
6861
  var number = modifiers && modifiers.number;
6800
6862
  var selectedVal = "Array.prototype.filter" +
@@ -6997,12 +7059,12 @@ function updateDOMProps (oldVnode, vnode) {
6997
7059
  function shouldUpdateValue (elm, checkVal) {
6998
7060
  return (!elm.composing && (
6999
7061
  elm.tagName === 'OPTION' ||
7000
- isDirty(elm, checkVal) ||
7001
- isInputChanged(elm, checkVal)
7062
+ isNotInFocusAndDirty(elm, checkVal) ||
7063
+ isDirtyWithModifiers(elm, checkVal)
7002
7064
  ))
7003
7065
  }
7004
7066
 
7005
- function isDirty (elm, checkVal) {
7067
+ function isNotInFocusAndDirty (elm, checkVal) {
7006
7068
  // return true when textbox (.number and .trim) loses focus and its value is
7007
7069
  // not equal to the updated value
7008
7070
  var notInFocus = true;
@@ -7012,14 +7074,20 @@ function isDirty (elm, checkVal) {
7012
7074
  return notInFocus && elm.value !== checkVal
7013
7075
  }
7014
7076
 
7015
- function isInputChanged (elm, newVal) {
7077
+ function isDirtyWithModifiers (elm, newVal) {
7016
7078
  var value = elm.value;
7017
7079
  var modifiers = elm._vModifiers; // injected by v-model runtime
7018
- if (isDef(modifiers) && modifiers.number) {
7019
- return toNumber(value) !== toNumber(newVal)
7020
- }
7021
- if (isDef(modifiers) && modifiers.trim) {
7022
- return value.trim() !== newVal.trim()
7080
+ if (isDef(modifiers)) {
7081
+ if (modifiers.lazy) {
7082
+ // inputs with lazy should only be updated when not in focus
7083
+ return false
7084
+ }
7085
+ if (modifiers.number) {
7086
+ return toNumber(value) !== toNumber(newVal)
7087
+ }
7088
+ if (modifiers.trim) {
7089
+ return value.trim() !== newVal.trim()
7090
+ }
7023
7091
  }
7024
7092
  return value !== newVal
7025
7093
  }
@@ -7077,7 +7145,10 @@ function getStyle (vnode, checkChild) {
7077
7145
  var childNode = vnode;
7078
7146
  while (childNode.componentInstance) {
7079
7147
  childNode = childNode.componentInstance._vnode;
7080
- if (childNode.data && (styleData = normalizeStyleData(childNode.data))) {
7148
+ if (
7149
+ childNode && childNode.data &&
7150
+ (styleData = normalizeStyleData(childNode.data))
7151
+ ) {
7081
7152
  extend(res, styleData);
7082
7153
  }
7083
7154
  }
@@ -8233,7 +8304,7 @@ var TransitionGroup = {
8233
8304
  this._vnode,
8234
8305
  this.kept,
8235
8306
  false, // hydrating
8236
- true // removeOnly (!important, avoids unnecessary moves)
8307
+ true // removeOnly (!important avoids unnecessary moves)
8237
8308
  );
8238
8309
  this._vnode = this.kept;
8239
8310
  },
@@ -8396,6 +8467,8 @@ var buildRegex = cached(function (delimiters) {
8396
8467
  return new RegExp(open + '((?:.|\\n)+?)' + close, 'g')
8397
8468
  });
8398
8469
 
8470
+
8471
+
8399
8472
  function parseText (
8400
8473
  text,
8401
8474
  delimiters
@@ -8405,23 +8478,30 @@ function parseText (
8405
8478
  return
8406
8479
  }
8407
8480
  var tokens = [];
8481
+ var rawTokens = [];
8408
8482
  var lastIndex = tagRE.lastIndex = 0;
8409
- var match, index;
8483
+ var match, index, tokenValue;
8410
8484
  while ((match = tagRE.exec(text))) {
8411
8485
  index = match.index;
8412
8486
  // push text token
8413
8487
  if (index > lastIndex) {
8414
- tokens.push(JSON.stringify(text.slice(lastIndex, index)));
8488
+ rawTokens.push(tokenValue = text.slice(lastIndex, index));
8489
+ tokens.push(JSON.stringify(tokenValue));
8415
8490
  }
8416
8491
  // tag token
8417
8492
  var exp = parseFilters(match[1].trim());
8418
8493
  tokens.push(("_s(" + exp + ")"));
8494
+ rawTokens.push({ '@binding': exp });
8419
8495
  lastIndex = index + match[0].length;
8420
8496
  }
8421
8497
  if (lastIndex < text.length) {
8422
- tokens.push(JSON.stringify(text.slice(lastIndex)));
8498
+ rawTokens.push(tokenValue = text.slice(lastIndex));
8499
+ tokens.push(JSON.stringify(tokenValue));
8500
+ }
8501
+ return {
8502
+ expression: tokens.join('+'),
8503
+ tokens: rawTokens
8423
8504
  }
8424
- return tokens.join('+')
8425
8505
  }
8426
8506
 
8427
8507
  /* */
@@ -8430,8 +8510,8 @@ function transformNode (el, options) {
8430
8510
  var warn = options.warn || baseWarn;
8431
8511
  var staticClass = getAndRemoveAttr(el, 'class');
8432
8512
  if (process.env.NODE_ENV !== 'production' && staticClass) {
8433
- var expression = parseText(staticClass, options.delimiters);
8434
- if (expression) {
8513
+ var res = parseText(staticClass, options.delimiters);
8514
+ if (res) {
8435
8515
  warn(
8436
8516
  "class=\"" + staticClass + "\": " +
8437
8517
  'Interpolation inside attributes has been removed. ' +
@@ -8474,8 +8554,8 @@ function transformNode$1 (el, options) {
8474
8554
  if (staticStyle) {
8475
8555
  /* istanbul ignore if */
8476
8556
  if (process.env.NODE_ENV !== 'production') {
8477
- var expression = parseText(staticStyle, options.delimiters);
8478
- if (expression) {
8557
+ var res = parseText(staticStyle, options.delimiters);
8558
+ if (res) {
8479
8559
  warn(
8480
8560
  "style=\"" + staticStyle + "\": " +
8481
8561
  'Interpolation inside attributes has been removed. ' +
@@ -8857,7 +8937,7 @@ function parseHTML (html, options) {
8857
8937
  var onRE = /^@|^v-on:/;
8858
8938
  var dirRE = /^v-|^@|^:/;
8859
8939
  var forAliasRE = /(.*?)\s+(?:in|of)\s+(.*)/;
8860
- var forIteratorRE = /\((\{[^}]*\}|[^,{]*),([^,]*)(?:,([^,]*))?\)/;
8940
+ var forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
8861
8941
  var stripParensRE = /^\(|\)$/g;
8862
8942
 
8863
8943
  var argRE = /:(.*)$/;
@@ -8927,7 +9007,7 @@ function parse (
8927
9007
  }
8928
9008
  }
8929
9009
 
8930
- function endPre (element) {
9010
+ function closeElement (element) {
8931
9011
  // check pre state
8932
9012
  if (element.pre) {
8933
9013
  inVPre = false;
@@ -8935,6 +9015,10 @@ function parse (
8935
9015
  if (platformIsPreTag(element.tag)) {
8936
9016
  inPre = false;
8937
9017
  }
9018
+ // apply post-transforms
9019
+ for (var i = 0; i < postTransforms.length; i++) {
9020
+ postTransforms[i](element, options);
9021
+ }
8938
9022
  }
8939
9023
 
8940
9024
  parseHTML(template, {
@@ -9047,11 +9131,7 @@ function parse (
9047
9131
  currentParent = element;
9048
9132
  stack.push(element);
9049
9133
  } else {
9050
- endPre(element);
9051
- }
9052
- // apply post-transforms
9053
- for (var i$1 = 0; i$1 < postTransforms.length; i$1++) {
9054
- postTransforms[i$1](element, options);
9134
+ closeElement(element);
9055
9135
  }
9056
9136
  },
9057
9137
 
@@ -9065,7 +9145,7 @@ function parse (
9065
9145
  // pop stack
9066
9146
  stack.length -= 1;
9067
9147
  currentParent = stack[stack.length - 1];
9068
- endPre(element);
9148
+ closeElement(element);
9069
9149
  },
9070
9150
 
9071
9151
  chars: function chars (text) {
@@ -9097,11 +9177,12 @@ function parse (
9097
9177
  // only preserve whitespace if its not right after a starting tag
9098
9178
  : preserveWhitespace && children.length ? ' ' : '';
9099
9179
  if (text) {
9100
- var expression;
9101
- if (!inVPre && text !== ' ' && (expression = parseText(text, delimiters))) {
9180
+ var res;
9181
+ if (!inVPre && text !== ' ' && (res = parseText(text, delimiters))) {
9102
9182
  children.push({
9103
9183
  type: 2,
9104
- expression: expression,
9184
+ expression: res.expression,
9185
+ tokens: res.tokens,
9105
9186
  text: text
9106
9187
  });
9107
9188
  } else if (text !== ' ' || !children.length || children[children.length - 1].text !== ' ') {
@@ -9182,26 +9263,34 @@ function processRef (el) {
9182
9263
  function processFor (el) {
9183
9264
  var exp;
9184
9265
  if ((exp = getAndRemoveAttr(el, 'v-for'))) {
9185
- var inMatch = exp.match(forAliasRE);
9186
- if (!inMatch) {
9187
- process.env.NODE_ENV !== 'production' && warn$2(
9266
+ var res = parseFor(exp);
9267
+ if (res) {
9268
+ extend(el, res);
9269
+ } else if (process.env.NODE_ENV !== 'production') {
9270
+ warn$2(
9188
9271
  ("Invalid v-for expression: " + exp)
9189
9272
  );
9190
- return
9191
9273
  }
9192
- el.for = inMatch[2].trim();
9193
- var alias = inMatch[1].trim();
9194
- var iteratorMatch = alias.match(forIteratorRE);
9195
- if (iteratorMatch) {
9196
- el.alias = iteratorMatch[1].trim();
9197
- el.iterator1 = iteratorMatch[2].trim();
9198
- if (iteratorMatch[3]) {
9199
- el.iterator2 = iteratorMatch[3].trim();
9200
- }
9201
- } else {
9202
- el.alias = alias.replace(stripParensRE, '');
9274
+ }
9275
+ }
9276
+
9277
+ function parseFor (exp) {
9278
+ var inMatch = exp.match(forAliasRE);
9279
+ if (!inMatch) { return }
9280
+ var res = {};
9281
+ res.for = inMatch[2].trim();
9282
+ var alias = inMatch[1].trim().replace(stripParensRE, '');
9283
+ var iteratorMatch = alias.match(forIteratorRE);
9284
+ if (iteratorMatch) {
9285
+ res.alias = alias.replace(forIteratorRE, '');
9286
+ res.iterator1 = iteratorMatch[1].trim();
9287
+ if (iteratorMatch[2]) {
9288
+ res.iterator2 = iteratorMatch[2].trim();
9203
9289
  }
9290
+ } else {
9291
+ res.alias = alias;
9204
9292
  }
9293
+ return res
9205
9294
  }
9206
9295
 
9207
9296
  function processIf (el) {
@@ -9389,8 +9478,8 @@ function processAttrs (el) {
9389
9478
  } else {
9390
9479
  // literal attribute
9391
9480
  if (process.env.NODE_ENV !== 'production') {
9392
- var expression = parseText(value, delimiters);
9393
- if (expression) {
9481
+ var res = parseText(value, delimiters);
9482
+ if (res) {
9394
9483
  warn$2(
9395
9484
  name + "=\"" + value + "\": " +
9396
9485
  'Interpolation inside attributes has been removed. ' +
@@ -9559,11 +9648,6 @@ function cloneASTElement (el) {
9559
9648
  return createASTElement(el.tag, el.attrsList.slice(), el.parent)
9560
9649
  }
9561
9650
 
9562
- function addRawAttr (el, name, value) {
9563
- el.attrsMap[name] = value;
9564
- el.attrsList.push({ name: name, value: value });
9565
- }
9566
-
9567
9651
  var model$2 = {
9568
9652
  preTransformNode: preTransformNode
9569
9653
  };
@@ -9802,9 +9886,11 @@ function genHandler (
9802
9886
  var isFunctionExpression = fnExpRE.test(handler.value);
9803
9887
 
9804
9888
  if (!handler.modifiers) {
9805
- return isMethodPath || isFunctionExpression
9806
- ? handler.value
9807
- : ("function($event){" + (handler.value) + "}") // inline statement
9889
+ if (isMethodPath || isFunctionExpression) {
9890
+ return handler.value
9891
+ }
9892
+ /* istanbul ignore if */
9893
+ return ("function($event){" + (handler.value) + "}") // inline statement
9808
9894
  } else {
9809
9895
  var code = '';
9810
9896
  var genModifierCode = '';
@@ -9840,6 +9926,7 @@ function genHandler (
9840
9926
  : isFunctionExpression
9841
9927
  ? ("(" + (handler.value) + ")($event)")
9842
9928
  : handler.value;
9929
+ /* istanbul ignore if */
9843
9930
  return ("function($event){" + code + handlerCode + "}")
9844
9931
  }
9845
9932
  }
@@ -9948,10 +10035,10 @@ function genElement (el, state) {
9948
10035
  }
9949
10036
 
9950
10037
  // hoist static sub-trees out
9951
- function genStatic (el, state, once$$1) {
10038
+ function genStatic (el, state) {
9952
10039
  el.staticProcessed = true;
9953
10040
  state.staticRenderFns.push(("with(this){return " + (genElement(el, state)) + "}"));
9954
- return ("_m(" + (state.staticRenderFns.length - 1) + "," + (el.staticInFor ? 'true' : 'false') + "," + (once$$1 ? 'true' : 'false') + ")")
10041
+ return ("_m(" + (state.staticRenderFns.length - 1) + (el.staticInFor ? ',true' : '') + ")")
9955
10042
  }
9956
10043
 
9957
10044
  // v-once
@@ -9977,7 +10064,7 @@ function genOnce (el, state) {
9977
10064
  }
9978
10065
  return ("_o(" + (genElement(el, state)) + "," + (state.onceId++) + "," + key + ")")
9979
10066
  } else {
9980
- return genStatic(el, state, true)
10067
+ return genStatic(el, state)
9981
10068
  }
9982
10069
  }
9983
10070
 
@@ -10317,7 +10404,10 @@ function genProps (props) {
10317
10404
  var res = '';
10318
10405
  for (var i = 0; i < props.length; i++) {
10319
10406
  var prop = props[i];
10320
- res += "\"" + (prop.name) + "\":" + (transformSpecialNewlines(prop.value)) + ",";
10407
+ /* istanbul ignore if */
10408
+ {
10409
+ res += "\"" + (prop.name) + "\":" + (transformSpecialNewlines(prop.value)) + ",";
10410
+ }
10321
10411
  }
10322
10412
  return res.slice(0, -1)
10323
10413
  }
@@ -10557,7 +10647,7 @@ function createCompilerCreator (baseCompile) {
10557
10647
  // merge custom directives
10558
10648
  if (options.directives) {
10559
10649
  finalOptions.directives = extend(
10560
- Object.create(baseOptions.directives),
10650
+ Object.create(baseOptions.directives || null),
10561
10651
  options.directives
10562
10652
  );
10563
10653
  }
@@ -10595,7 +10685,9 @@ var createCompiler = createCompilerCreator(function baseCompile (
10595
10685
  options
10596
10686
  ) {
10597
10687
  var ast = parse(template.trim(), options);
10598
- optimize(ast, options);
10688
+ if (options.optimize !== false) {
10689
+ optimize(ast, options);
10690
+ }
10599
10691
  var code = generate(ast, options);
10600
10692
  return {
10601
10693
  ast: ast,