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.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
  */
@@ -38,6 +38,8 @@ function isPrimitive (value) {
38
38
  return (
39
39
  typeof value === 'string' ||
40
40
  typeof value === 'number' ||
41
+ // $flow-disable-line
42
+ typeof value === 'symbol' ||
41
43
  typeof value === 'boolean'
42
44
  )
43
45
  }
@@ -346,6 +348,7 @@ var config = ({
346
348
  /**
347
349
  * Option merge strategies (used in core/util/options)
348
350
  */
351
+ // $flow-disable-line
349
352
  optionMergeStrategies: Object.create(null),
350
353
 
351
354
  /**
@@ -386,6 +389,7 @@ var config = ({
386
389
  /**
387
390
  * Custom user key aliases for v-on
388
391
  */
392
+ // $flow-disable-line
389
393
  keyCodes: Object.create(null),
390
394
 
391
395
  /**
@@ -820,8 +824,7 @@ var arrayMethods = Object.create(arrayProto);[
820
824
  'splice',
821
825
  'sort',
822
826
  'reverse'
823
- ]
824
- .forEach(function (method) {
827
+ ].forEach(function (method) {
825
828
  // cache original method
826
829
  var original = arrayProto[method];
827
830
  def(arrayMethods, method, function mutator () {
@@ -1153,18 +1156,18 @@ function mergeDataOrFn (
1153
1156
  // it has to be a function to pass previous merges.
1154
1157
  return function mergedDataFn () {
1155
1158
  return mergeData(
1156
- typeof childVal === 'function' ? childVal.call(this) : childVal,
1157
- typeof parentVal === 'function' ? parentVal.call(this) : parentVal
1159
+ typeof childVal === 'function' ? childVal.call(this, this) : childVal,
1160
+ typeof parentVal === 'function' ? parentVal.call(this, this) : parentVal
1158
1161
  )
1159
1162
  }
1160
1163
  } else {
1161
1164
  return function mergedInstanceDataFn () {
1162
1165
  // instance merge
1163
1166
  var instanceData = typeof childVal === 'function'
1164
- ? childVal.call(vm)
1167
+ ? childVal.call(vm, vm)
1165
1168
  : childVal;
1166
1169
  var defaultData = typeof parentVal === 'function'
1167
- ? parentVal.call(vm)
1170
+ ? parentVal.call(vm, vm)
1168
1171
  : parentVal;
1169
1172
  if (instanceData) {
1170
1173
  return mergeData(instanceData, defaultData)
@@ -1316,13 +1319,23 @@ var defaultStrat = function (parentVal, childVal) {
1316
1319
  */
1317
1320
  function checkComponents (options) {
1318
1321
  for (var key in options.components) {
1319
- var lower = key.toLowerCase();
1320
- if (isBuiltInTag(lower) || config.isReservedTag(lower)) {
1321
- warn(
1322
- 'Do not use built-in or reserved HTML elements as component ' +
1323
- 'id: ' + key
1324
- );
1325
- }
1322
+ validateComponentName(key);
1323
+ }
1324
+ }
1325
+
1326
+ function validateComponentName (name) {
1327
+ if (!/^[a-zA-Z][\w-]*$/.test(name)) {
1328
+ warn(
1329
+ 'Invalid component name: "' + name + '". Component names ' +
1330
+ 'can only contain alphanumeric characters and the hyphen, ' +
1331
+ 'and must start with a letter.'
1332
+ );
1333
+ }
1334
+ if (isBuiltInTag(name) || config.isReservedTag(name)) {
1335
+ warn(
1336
+ 'Do not use built-in or reserved HTML elements as component ' +
1337
+ 'id: ' + name
1338
+ );
1326
1339
  }
1327
1340
  }
1328
1341
 
@@ -1369,6 +1382,7 @@ function normalizeProps (options, vm) {
1369
1382
  */
1370
1383
  function normalizeInject (options, vm) {
1371
1384
  var inject = options.inject;
1385
+ if (!inject) { return }
1372
1386
  var normalized = options.inject = {};
1373
1387
  if (Array.isArray(inject)) {
1374
1388
  for (var i = 0; i < inject.length; i++) {
@@ -1381,7 +1395,7 @@ function normalizeInject (options, vm) {
1381
1395
  ? extend({ from: key }, val)
1382
1396
  : { from: val };
1383
1397
  }
1384
- } else if ("development" !== 'production' && inject) {
1398
+ } else {
1385
1399
  warn(
1386
1400
  "Invalid value for option \"inject\": expected an Array or an Object, " +
1387
1401
  "but got " + (toRawType(inject)) + ".",
@@ -2003,11 +2017,12 @@ function updateListeners (
2003
2017
  remove$$1,
2004
2018
  vm
2005
2019
  ) {
2006
- var name, cur, old, event;
2020
+ var name, def, cur, old, event;
2007
2021
  for (name in on) {
2008
- cur = on[name];
2022
+ def = cur = on[name];
2009
2023
  old = oldOn[name];
2010
2024
  event = normalizeEvent(name);
2025
+ /* istanbul ignore if */
2011
2026
  if (isUndef(cur)) {
2012
2027
  "development" !== 'production' && warn(
2013
2028
  "Invalid handler for event \"" + (event.name) + "\": got " + String(cur),
@@ -2017,7 +2032,7 @@ function updateListeners (
2017
2032
  if (isUndef(cur.fns)) {
2018
2033
  cur = on[name] = createFnInvoker(cur);
2019
2034
  }
2020
- add(event.name, cur, event.once, event.capture, event.passive);
2035
+ add(event.name, cur, event.once, event.capture, event.passive, event.params);
2021
2036
  } else if (cur !== old) {
2022
2037
  old.fns = cur;
2023
2038
  on[name] = old;
@@ -2509,6 +2524,8 @@ function eventsMixin (Vue) {
2509
2524
 
2510
2525
  /* */
2511
2526
 
2527
+
2528
+
2512
2529
  /**
2513
2530
  * Runtime helper for resolving raw children VNodes into a slot object.
2514
2531
  */
@@ -2532,10 +2549,10 @@ function resolveSlots (
2532
2549
  if ((child.context === context || child.fnContext === context) &&
2533
2550
  data && data.slot != null
2534
2551
  ) {
2535
- var name = child.data.slot;
2552
+ var name = data.slot;
2536
2553
  var slot = (slots[name] || (slots[name] = []));
2537
2554
  if (child.tag === 'template') {
2538
- slot.push.apply(slot, child.children);
2555
+ slot.push.apply(slot, child.children || []);
2539
2556
  } else {
2540
2557
  slot.push(child);
2541
2558
  }
@@ -3372,6 +3389,7 @@ function getData (data, vm) {
3372
3389
  var computedWatcherOptions = { lazy: true };
3373
3390
 
3374
3391
  function initComputed (vm, computed) {
3392
+ // $flow-disable-line
3375
3393
  var watchers = vm._computedWatchers = Object.create(null);
3376
3394
  // computed properties are just getters during SSR
3377
3395
  var isSSR = isServerRendering();
@@ -3600,11 +3618,11 @@ function resolveInject (inject, vm) {
3600
3618
  // inject is :any because flow is not smart enough to figure out cached
3601
3619
  var result = Object.create(null);
3602
3620
  var keys = hasSymbol
3603
- ? Reflect.ownKeys(inject).filter(function (key) {
3604
- /* istanbul ignore next */
3605
- return Object.getOwnPropertyDescriptor(inject, key).enumerable
3606
- })
3607
- : Object.keys(inject);
3621
+ ? Reflect.ownKeys(inject).filter(function (key) {
3622
+ /* istanbul ignore next */
3623
+ return Object.getOwnPropertyDescriptor(inject, key).enumerable
3624
+ })
3625
+ : Object.keys(inject);
3608
3626
 
3609
3627
  for (var i = 0; i < keys.length; i++) {
3610
3628
  var key = keys[i];
@@ -3810,19 +3828,9 @@ function bindObjectProps (
3810
3828
  */
3811
3829
  function renderStatic (
3812
3830
  index,
3813
- isInFor,
3814
- isOnce
3831
+ isInFor
3815
3832
  ) {
3816
- // render fns generated by compiler < 2.5.4 does not provide v-once
3817
- // information to runtime so be conservative
3818
- var isOldVersion = arguments.length < 3;
3819
- // if a static tree is generated by v-once, it is cached on the instance;
3820
- // otherwise it is purely static and can be cached on the shared options
3821
- // across all instances.
3822
- var renderFns = this.$options.staticRenderFns;
3823
- var cached = isOldVersion || isOnce
3824
- ? (this._staticTrees || (this._staticTrees = []))
3825
- : (renderFns.cached || (renderFns.cached = []));
3833
+ var cached = this._staticTrees || (this._staticTrees = []);
3826
3834
  var tree = cached[index];
3827
3835
  // if has already-rendered static tree and not inside v-for,
3828
3836
  // we can reuse the same tree by doing a shallow clone.
@@ -3832,7 +3840,11 @@ function renderStatic (
3832
3840
  : cloneVNode(tree)
3833
3841
  }
3834
3842
  // otherwise, render a fresh tree.
3835
- tree = cached[index] = renderFns[index].call(this._renderProxy, null, this);
3843
+ tree = cached[index] = this.$options.staticRenderFns[index].call(
3844
+ this._renderProxy,
3845
+ null,
3846
+ this // for render fns generated for functional component templates
3847
+ );
3836
3848
  markStatic(tree, ("__static__" + index), false);
3837
3849
  return tree
3838
3850
  }
@@ -4010,6 +4022,25 @@ function mergeProps (to, from) {
4010
4022
 
4011
4023
  /* */
4012
4024
 
4025
+
4026
+
4027
+
4028
+ // Register the component hook to weex native render engine.
4029
+ // The hook will be triggered by native, not javascript.
4030
+
4031
+
4032
+ // Updates the state of the component to weex native render engine.
4033
+
4034
+ /* */
4035
+
4036
+ // https://github.com/Hanks10100/weex-native-directive/tree/master/component
4037
+
4038
+ // listening on native callback
4039
+
4040
+ /* */
4041
+
4042
+ /* */
4043
+
4013
4044
  // hooks to be invoked on component VNodes during patch
4014
4045
  var componentVNodeHooks = {
4015
4046
  init: function init (
@@ -4175,6 +4206,11 @@ function createComponent (
4175
4206
  { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children },
4176
4207
  asyncFactory
4177
4208
  );
4209
+
4210
+ // Weex specific: invoke recycle-list optimized @render function for
4211
+ // extracting cell-slot template.
4212
+ // https://github.com/Hanks10100/weex-native-directive/tree/master/component
4213
+ /* istanbul ignore if */
4178
4214
  return vnode
4179
4215
  }
4180
4216
 
@@ -4184,15 +4220,10 @@ function createComponentInstanceForVnode (
4184
4220
  parentElm,
4185
4221
  refElm
4186
4222
  ) {
4187
- var vnodeComponentOptions = vnode.componentOptions;
4188
4223
  var options = {
4189
4224
  _isComponent: true,
4190
4225
  parent: parent,
4191
- propsData: vnodeComponentOptions.propsData,
4192
- _componentTag: vnodeComponentOptions.tag,
4193
4226
  _parentVnode: vnode,
4194
- _parentListeners: vnodeComponentOptions.listeners,
4195
- _renderChildren: vnodeComponentOptions.children,
4196
4227
  _parentElm: parentElm || null,
4197
4228
  _refElm: refElm || null
4198
4229
  };
@@ -4202,7 +4233,7 @@ function createComponentInstanceForVnode (
4202
4233
  options.render = inlineTemplate.render;
4203
4234
  options.staticRenderFns = inlineTemplate.staticRenderFns;
4204
4235
  }
4205
- return new vnodeComponentOptions.Ctor(options)
4236
+ return new vnode.componentOptions.Ctor(options)
4206
4237
  }
4207
4238
 
4208
4239
  function mergeHooks (data) {
@@ -4290,11 +4321,13 @@ function _createElement (
4290
4321
  if ("development" !== 'production' &&
4291
4322
  isDef(data) && isDef(data.key) && !isPrimitive(data.key)
4292
4323
  ) {
4293
- warn(
4294
- 'Avoid using non-primitive value as key, ' +
4295
- 'use string/number value instead.',
4296
- context
4297
- );
4324
+ {
4325
+ warn(
4326
+ 'Avoid using non-primitive value as key, ' +
4327
+ 'use string/number value instead.',
4328
+ context
4329
+ );
4330
+ }
4298
4331
  }
4299
4332
  // support single function children as default scoped slot
4300
4333
  if (Array.isArray(children) &&
@@ -4529,14 +4562,18 @@ function initMixin (Vue) {
4529
4562
  function initInternalComponent (vm, options) {
4530
4563
  var opts = vm.$options = Object.create(vm.constructor.options);
4531
4564
  // doing this because it's faster than dynamic enumeration.
4565
+ var parentVnode = options._parentVnode;
4532
4566
  opts.parent = options.parent;
4533
- opts.propsData = options.propsData;
4534
- opts._parentVnode = options._parentVnode;
4535
- opts._parentListeners = options._parentListeners;
4536
- opts._renderChildren = options._renderChildren;
4537
- opts._componentTag = options._componentTag;
4567
+ opts._parentVnode = parentVnode;
4538
4568
  opts._parentElm = options._parentElm;
4539
4569
  opts._refElm = options._refElm;
4570
+
4571
+ var vnodeComponentOptions = parentVnode.componentOptions;
4572
+ opts.propsData = vnodeComponentOptions.propsData;
4573
+ opts._parentListeners = vnodeComponentOptions.listeners;
4574
+ opts._renderChildren = vnodeComponentOptions.children;
4575
+ opts._componentTag = vnodeComponentOptions.tag;
4576
+
4540
4577
  if (options.render) {
4541
4578
  opts.render = options.render;
4542
4579
  opts.staticRenderFns = options.staticRenderFns;
@@ -4670,14 +4707,8 @@ function initExtend (Vue) {
4670
4707
  }
4671
4708
 
4672
4709
  var name = extendOptions.name || Super.options.name;
4673
- {
4674
- if (!/^[a-zA-Z][\w-]*$/.test(name)) {
4675
- warn(
4676
- 'Invalid component name: "' + name + '". Component names ' +
4677
- 'can only contain alphanumeric characters and the hyphen, ' +
4678
- 'and must start with a letter.'
4679
- );
4680
- }
4710
+ if ("development" !== 'production' && name) {
4711
+ validateComponentName(name);
4681
4712
  }
4682
4713
 
4683
4714
  var Sub = function VueComponent (options) {
@@ -4759,13 +4790,8 @@ function initAssetRegisters (Vue) {
4759
4790
  return this.options[type + 's'][id]
4760
4791
  } else {
4761
4792
  /* istanbul ignore if */
4762
- {
4763
- if (type === 'component' && config.isReservedTag(id)) {
4764
- warn(
4765
- 'Do not use built-in or reserved HTML elements as component ' +
4766
- 'id: ' + id
4767
- );
4768
- }
4793
+ if ("development" !== 'production' && type === 'component') {
4794
+ validateComponentName(id);
4769
4795
  }
4770
4796
  if (type === 'component' && isPlainObject(definition)) {
4771
4797
  definition.name = definition.name || id;
@@ -4972,7 +4998,7 @@ Object.defineProperty(Vue$3.prototype, '$ssrContext', {
4972
4998
  }
4973
4999
  });
4974
5000
 
4975
- Vue$3.version = '2.5.9';
5001
+ Vue$3.version = '2.5.13';
4976
5002
 
4977
5003
  /* */
4978
5004
 
@@ -5024,12 +5050,12 @@ function genClassForVnode (vnode) {
5024
5050
  var childNode = vnode;
5025
5051
  while (isDef(childNode.componentInstance)) {
5026
5052
  childNode = childNode.componentInstance._vnode;
5027
- if (childNode.data) {
5053
+ if (childNode && childNode.data) {
5028
5054
  data = mergeClassData(childNode.data, data);
5029
5055
  }
5030
5056
  }
5031
5057
  while (isDef(parentNode = parentNode.parent)) {
5032
- if (parentNode.data) {
5058
+ if (parentNode && parentNode.data) {
5033
5059
  data = mergeClassData(data, parentNode.data);
5034
5060
  }
5035
5061
  }
@@ -5540,11 +5566,14 @@ function createPatchFunction (backend) {
5540
5566
 
5541
5567
  function createChildren (vnode, children, insertedVnodeQueue) {
5542
5568
  if (Array.isArray(children)) {
5569
+ {
5570
+ checkDuplicateKeys(children);
5571
+ }
5543
5572
  for (var i = 0; i < children.length; ++i) {
5544
5573
  createElm(children[i], insertedVnodeQueue, vnode.elm, null, true);
5545
5574
  }
5546
5575
  } else if (isPrimitive(vnode.text)) {
5547
- nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(vnode.text));
5576
+ nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(String(vnode.text)));
5548
5577
  }
5549
5578
  }
5550
5579
 
@@ -5671,6 +5700,10 @@ function createPatchFunction (backend) {
5671
5700
  // during leaving transitions
5672
5701
  var canMove = !removeOnly;
5673
5702
 
5703
+ {
5704
+ checkDuplicateKeys(newCh);
5705
+ }
5706
+
5674
5707
  while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
5675
5708
  if (isUndef(oldStartVnode)) {
5676
5709
  oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left
@@ -5703,13 +5736,6 @@ function createPatchFunction (backend) {
5703
5736
  createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm);
5704
5737
  } else {
5705
5738
  vnodeToMove = oldCh[idxInOld];
5706
- /* istanbul ignore if */
5707
- if ("development" !== 'production' && !vnodeToMove) {
5708
- warn(
5709
- 'It seems there are duplicate keys that is causing an update error. ' +
5710
- 'Make sure each v-for item has a unique key.'
5711
- );
5712
- }
5713
5739
  if (sameVnode(vnodeToMove, newStartVnode)) {
5714
5740
  patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue);
5715
5741
  oldCh[idxInOld] = undefined;
@@ -5730,6 +5756,24 @@ function createPatchFunction (backend) {
5730
5756
  }
5731
5757
  }
5732
5758
 
5759
+ function checkDuplicateKeys (children) {
5760
+ var seenKeys = {};
5761
+ for (var i = 0; i < children.length; i++) {
5762
+ var vnode = children[i];
5763
+ var key = vnode.key;
5764
+ if (isDef(key)) {
5765
+ if (seenKeys[key]) {
5766
+ warn(
5767
+ ("Duplicate keys detected: '" + key + "'. This may cause an update error."),
5768
+ vnode.context
5769
+ );
5770
+ } else {
5771
+ seenKeys[key] = true;
5772
+ }
5773
+ }
5774
+ }
5775
+ }
5776
+
5733
5777
  function findIdxInOld (node, oldCh, start, end) {
5734
5778
  for (var i = start; i < end; i++) {
5735
5779
  var c = oldCh[i];
@@ -6112,17 +6156,20 @@ function normalizeDirectives$1 (
6112
6156
  ) {
6113
6157
  var res = Object.create(null);
6114
6158
  if (!dirs) {
6159
+ // $flow-disable-line
6115
6160
  return res
6116
6161
  }
6117
6162
  var i, dir;
6118
6163
  for (i = 0; i < dirs.length; i++) {
6119
6164
  dir = dirs[i];
6120
6165
  if (!dir.modifiers) {
6166
+ // $flow-disable-line
6121
6167
  dir.modifiers = emptyModifiers;
6122
6168
  }
6123
6169
  res[getRawDirName(dir)] = dir;
6124
6170
  dir.def = resolveAsset(vm.$options, 'directives', dir.name, true);
6125
6171
  }
6172
+ // $flow-disable-line
6126
6173
  return res
6127
6174
  }
6128
6175
 
@@ -6395,10 +6442,18 @@ function pluckModuleFunction (
6395
6442
 
6396
6443
  function addProp (el, name, value) {
6397
6444
  (el.props || (el.props = [])).push({ name: name, value: value });
6445
+ el.plain = false;
6398
6446
  }
6399
6447
 
6400
6448
  function addAttr (el, name, value) {
6401
6449
  (el.attrs || (el.attrs = [])).push({ name: name, value: value });
6450
+ el.plain = false;
6451
+ }
6452
+
6453
+ // add a raw attr (use this in preTransforms)
6454
+ function addRawAttr (el, name, value) {
6455
+ el.attrsMap[name] = value;
6456
+ el.attrsList.push({ name: name, value: value });
6402
6457
  }
6403
6458
 
6404
6459
  function addDirective (
@@ -6410,6 +6465,7 @@ function addDirective (
6410
6465
  modifiers
6411
6466
  ) {
6412
6467
  (el.directives || (el.directives = [])).push({ name: name, rawName: rawName, value: value, arg: arg, modifiers: modifiers });
6468
+ el.plain = false;
6413
6469
  }
6414
6470
 
6415
6471
  function addHandler (
@@ -6482,6 +6538,8 @@ function addHandler (
6482
6538
  } else {
6483
6539
  events[name] = newHandler;
6484
6540
  }
6541
+
6542
+ el.plain = false;
6485
6543
  }
6486
6544
 
6487
6545
  function getBindingAttr (
@@ -6748,11 +6806,11 @@ function genCheckboxModel (
6748
6806
  var falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
6749
6807
  addProp(el, 'checked',
6750
6808
  "Array.isArray(" + value + ")" +
6751
- "?_i(" + value + "," + valueBinding + ")>-1" + (
6752
- trueValueBinding === 'true'
6753
- ? (":(" + value + ")")
6754
- : (":_q(" + value + "," + trueValueBinding + ")")
6755
- )
6809
+ "?_i(" + value + "," + valueBinding + ")>-1" + (
6810
+ trueValueBinding === 'true'
6811
+ ? (":(" + value + ")")
6812
+ : (":_q(" + value + "," + trueValueBinding + ")")
6813
+ )
6756
6814
  );
6757
6815
  addHandler(el, 'change',
6758
6816
  "var $$a=" + value + "," +
@@ -6769,9 +6827,9 @@ function genCheckboxModel (
6769
6827
  }
6770
6828
 
6771
6829
  function genRadioModel (
6772
- el,
6773
- value,
6774
- modifiers
6830
+ el,
6831
+ value,
6832
+ modifiers
6775
6833
  ) {
6776
6834
  var number = modifiers && modifiers.number;
6777
6835
  var valueBinding = getBindingAttr(el, 'value') || 'null';
@@ -6781,9 +6839,9 @@ function genRadioModel (
6781
6839
  }
6782
6840
 
6783
6841
  function genSelect (
6784
- el,
6785
- value,
6786
- modifiers
6842
+ el,
6843
+ value,
6844
+ modifiers
6787
6845
  ) {
6788
6846
  var number = modifiers && modifiers.number;
6789
6847
  var selectedVal = "Array.prototype.filter" +
@@ -6986,12 +7044,12 @@ function updateDOMProps (oldVnode, vnode) {
6986
7044
  function shouldUpdateValue (elm, checkVal) {
6987
7045
  return (!elm.composing && (
6988
7046
  elm.tagName === 'OPTION' ||
6989
- isDirty(elm, checkVal) ||
6990
- isInputChanged(elm, checkVal)
7047
+ isNotInFocusAndDirty(elm, checkVal) ||
7048
+ isDirtyWithModifiers(elm, checkVal)
6991
7049
  ))
6992
7050
  }
6993
7051
 
6994
- function isDirty (elm, checkVal) {
7052
+ function isNotInFocusAndDirty (elm, checkVal) {
6995
7053
  // return true when textbox (.number and .trim) loses focus and its value is
6996
7054
  // not equal to the updated value
6997
7055
  var notInFocus = true;
@@ -7001,14 +7059,20 @@ function isDirty (elm, checkVal) {
7001
7059
  return notInFocus && elm.value !== checkVal
7002
7060
  }
7003
7061
 
7004
- function isInputChanged (elm, newVal) {
7062
+ function isDirtyWithModifiers (elm, newVal) {
7005
7063
  var value = elm.value;
7006
7064
  var modifiers = elm._vModifiers; // injected by v-model runtime
7007
- if (isDef(modifiers) && modifiers.number) {
7008
- return toNumber(value) !== toNumber(newVal)
7009
- }
7010
- if (isDef(modifiers) && modifiers.trim) {
7011
- return value.trim() !== newVal.trim()
7065
+ if (isDef(modifiers)) {
7066
+ if (modifiers.lazy) {
7067
+ // inputs with lazy should only be updated when not in focus
7068
+ return false
7069
+ }
7070
+ if (modifiers.number) {
7071
+ return toNumber(value) !== toNumber(newVal)
7072
+ }
7073
+ if (modifiers.trim) {
7074
+ return value.trim() !== newVal.trim()
7075
+ }
7012
7076
  }
7013
7077
  return value !== newVal
7014
7078
  }
@@ -7066,7 +7130,10 @@ function getStyle (vnode, checkChild) {
7066
7130
  var childNode = vnode;
7067
7131
  while (childNode.componentInstance) {
7068
7132
  childNode = childNode.componentInstance._vnode;
7069
- if (childNode.data && (styleData = normalizeStyleData(childNode.data))) {
7133
+ if (
7134
+ childNode && childNode.data &&
7135
+ (styleData = normalizeStyleData(childNode.data))
7136
+ ) {
7070
7137
  extend(res, styleData);
7071
7138
  }
7072
7139
  }
@@ -8222,7 +8289,7 @@ var TransitionGroup = {
8222
8289
  this._vnode,
8223
8290
  this.kept,
8224
8291
  false, // hydrating
8225
- true // removeOnly (!important, avoids unnecessary moves)
8292
+ true // removeOnly (!important avoids unnecessary moves)
8226
8293
  );
8227
8294
  this._vnode = this.kept;
8228
8295
  },
@@ -8385,6 +8452,8 @@ var buildRegex = cached(function (delimiters) {
8385
8452
  return new RegExp(open + '((?:.|\\n)+?)' + close, 'g')
8386
8453
  });
8387
8454
 
8455
+
8456
+
8388
8457
  function parseText (
8389
8458
  text,
8390
8459
  delimiters
@@ -8394,23 +8463,30 @@ function parseText (
8394
8463
  return
8395
8464
  }
8396
8465
  var tokens = [];
8466
+ var rawTokens = [];
8397
8467
  var lastIndex = tagRE.lastIndex = 0;
8398
- var match, index;
8468
+ var match, index, tokenValue;
8399
8469
  while ((match = tagRE.exec(text))) {
8400
8470
  index = match.index;
8401
8471
  // push text token
8402
8472
  if (index > lastIndex) {
8403
- tokens.push(JSON.stringify(text.slice(lastIndex, index)));
8473
+ rawTokens.push(tokenValue = text.slice(lastIndex, index));
8474
+ tokens.push(JSON.stringify(tokenValue));
8404
8475
  }
8405
8476
  // tag token
8406
8477
  var exp = parseFilters(match[1].trim());
8407
8478
  tokens.push(("_s(" + exp + ")"));
8479
+ rawTokens.push({ '@binding': exp });
8408
8480
  lastIndex = index + match[0].length;
8409
8481
  }
8410
8482
  if (lastIndex < text.length) {
8411
- tokens.push(JSON.stringify(text.slice(lastIndex)));
8483
+ rawTokens.push(tokenValue = text.slice(lastIndex));
8484
+ tokens.push(JSON.stringify(tokenValue));
8485
+ }
8486
+ return {
8487
+ expression: tokens.join('+'),
8488
+ tokens: rawTokens
8412
8489
  }
8413
- return tokens.join('+')
8414
8490
  }
8415
8491
 
8416
8492
  /* */
@@ -8419,8 +8495,8 @@ function transformNode (el, options) {
8419
8495
  var warn = options.warn || baseWarn;
8420
8496
  var staticClass = getAndRemoveAttr(el, 'class');
8421
8497
  if ("development" !== 'production' && staticClass) {
8422
- var expression = parseText(staticClass, options.delimiters);
8423
- if (expression) {
8498
+ var res = parseText(staticClass, options.delimiters);
8499
+ if (res) {
8424
8500
  warn(
8425
8501
  "class=\"" + staticClass + "\": " +
8426
8502
  'Interpolation inside attributes has been removed. ' +
@@ -8463,8 +8539,8 @@ function transformNode$1 (el, options) {
8463
8539
  if (staticStyle) {
8464
8540
  /* istanbul ignore if */
8465
8541
  {
8466
- var expression = parseText(staticStyle, options.delimiters);
8467
- if (expression) {
8542
+ var res = parseText(staticStyle, options.delimiters);
8543
+ if (res) {
8468
8544
  warn(
8469
8545
  "style=\"" + staticStyle + "\": " +
8470
8546
  'Interpolation inside attributes has been removed. ' +
@@ -8846,7 +8922,7 @@ function parseHTML (html, options) {
8846
8922
  var onRE = /^@|^v-on:/;
8847
8923
  var dirRE = /^v-|^@|^:/;
8848
8924
  var forAliasRE = /(.*?)\s+(?:in|of)\s+(.*)/;
8849
- var forIteratorRE = /\((\{[^}]*\}|[^,{]*),([^,]*)(?:,([^,]*))?\)/;
8925
+ var forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
8850
8926
  var stripParensRE = /^\(|\)$/g;
8851
8927
 
8852
8928
  var argRE = /:(.*)$/;
@@ -8916,7 +8992,7 @@ function parse (
8916
8992
  }
8917
8993
  }
8918
8994
 
8919
- function endPre (element) {
8995
+ function closeElement (element) {
8920
8996
  // check pre state
8921
8997
  if (element.pre) {
8922
8998
  inVPre = false;
@@ -8924,6 +9000,10 @@ function parse (
8924
9000
  if (platformIsPreTag(element.tag)) {
8925
9001
  inPre = false;
8926
9002
  }
9003
+ // apply post-transforms
9004
+ for (var i = 0; i < postTransforms.length; i++) {
9005
+ postTransforms[i](element, options);
9006
+ }
8927
9007
  }
8928
9008
 
8929
9009
  parseHTML(template, {
@@ -9036,11 +9116,7 @@ function parse (
9036
9116
  currentParent = element;
9037
9117
  stack.push(element);
9038
9118
  } else {
9039
- endPre(element);
9040
- }
9041
- // apply post-transforms
9042
- for (var i$1 = 0; i$1 < postTransforms.length; i$1++) {
9043
- postTransforms[i$1](element, options);
9119
+ closeElement(element);
9044
9120
  }
9045
9121
  },
9046
9122
 
@@ -9054,7 +9130,7 @@ function parse (
9054
9130
  // pop stack
9055
9131
  stack.length -= 1;
9056
9132
  currentParent = stack[stack.length - 1];
9057
- endPre(element);
9133
+ closeElement(element);
9058
9134
  },
9059
9135
 
9060
9136
  chars: function chars (text) {
@@ -9086,11 +9162,12 @@ function parse (
9086
9162
  // only preserve whitespace if its not right after a starting tag
9087
9163
  : preserveWhitespace && children.length ? ' ' : '';
9088
9164
  if (text) {
9089
- var expression;
9090
- if (!inVPre && text !== ' ' && (expression = parseText(text, delimiters))) {
9165
+ var res;
9166
+ if (!inVPre && text !== ' ' && (res = parseText(text, delimiters))) {
9091
9167
  children.push({
9092
9168
  type: 2,
9093
- expression: expression,
9169
+ expression: res.expression,
9170
+ tokens: res.tokens,
9094
9171
  text: text
9095
9172
  });
9096
9173
  } else if (text !== ' ' || !children.length || children[children.length - 1].text !== ' ') {
@@ -9171,26 +9248,34 @@ function processRef (el) {
9171
9248
  function processFor (el) {
9172
9249
  var exp;
9173
9250
  if ((exp = getAndRemoveAttr(el, 'v-for'))) {
9174
- var inMatch = exp.match(forAliasRE);
9175
- if (!inMatch) {
9176
- "development" !== 'production' && warn$2(
9251
+ var res = parseFor(exp);
9252
+ if (res) {
9253
+ extend(el, res);
9254
+ } else {
9255
+ warn$2(
9177
9256
  ("Invalid v-for expression: " + exp)
9178
9257
  );
9179
- return
9180
9258
  }
9181
- el.for = inMatch[2].trim();
9182
- var alias = inMatch[1].trim();
9183
- var iteratorMatch = alias.match(forIteratorRE);
9184
- if (iteratorMatch) {
9185
- el.alias = iteratorMatch[1].trim();
9186
- el.iterator1 = iteratorMatch[2].trim();
9187
- if (iteratorMatch[3]) {
9188
- el.iterator2 = iteratorMatch[3].trim();
9189
- }
9190
- } else {
9191
- el.alias = alias.replace(stripParensRE, '');
9259
+ }
9260
+ }
9261
+
9262
+ function parseFor (exp) {
9263
+ var inMatch = exp.match(forAliasRE);
9264
+ if (!inMatch) { return }
9265
+ var res = {};
9266
+ res.for = inMatch[2].trim();
9267
+ var alias = inMatch[1].trim().replace(stripParensRE, '');
9268
+ var iteratorMatch = alias.match(forIteratorRE);
9269
+ if (iteratorMatch) {
9270
+ res.alias = alias.replace(forIteratorRE, '');
9271
+ res.iterator1 = iteratorMatch[1].trim();
9272
+ if (iteratorMatch[2]) {
9273
+ res.iterator2 = iteratorMatch[2].trim();
9192
9274
  }
9275
+ } else {
9276
+ res.alias = alias;
9193
9277
  }
9278
+ return res
9194
9279
  }
9195
9280
 
9196
9281
  function processIf (el) {
@@ -9378,8 +9463,8 @@ function processAttrs (el) {
9378
9463
  } else {
9379
9464
  // literal attribute
9380
9465
  {
9381
- var expression = parseText(value, delimiters);
9382
- if (expression) {
9466
+ var res = parseText(value, delimiters);
9467
+ if (res) {
9383
9468
  warn$2(
9384
9469
  name + "=\"" + value + "\": " +
9385
9470
  'Interpolation inside attributes has been removed. ' +
@@ -9548,11 +9633,6 @@ function cloneASTElement (el) {
9548
9633
  return createASTElement(el.tag, el.attrsList.slice(), el.parent)
9549
9634
  }
9550
9635
 
9551
- function addRawAttr (el, name, value) {
9552
- el.attrsMap[name] = value;
9553
- el.attrsList.push({ name: name, value: value });
9554
- }
9555
-
9556
9636
  var model$2 = {
9557
9637
  preTransformNode: preTransformNode
9558
9638
  };
@@ -9791,9 +9871,11 @@ function genHandler (
9791
9871
  var isFunctionExpression = fnExpRE.test(handler.value);
9792
9872
 
9793
9873
  if (!handler.modifiers) {
9794
- return isMethodPath || isFunctionExpression
9795
- ? handler.value
9796
- : ("function($event){" + (handler.value) + "}") // inline statement
9874
+ if (isMethodPath || isFunctionExpression) {
9875
+ return handler.value
9876
+ }
9877
+ /* istanbul ignore if */
9878
+ return ("function($event){" + (handler.value) + "}") // inline statement
9797
9879
  } else {
9798
9880
  var code = '';
9799
9881
  var genModifierCode = '';
@@ -9829,6 +9911,7 @@ function genHandler (
9829
9911
  : isFunctionExpression
9830
9912
  ? ("(" + (handler.value) + ")($event)")
9831
9913
  : handler.value;
9914
+ /* istanbul ignore if */
9832
9915
  return ("function($event){" + code + handlerCode + "}")
9833
9916
  }
9834
9917
  }
@@ -9937,10 +10020,10 @@ function genElement (el, state) {
9937
10020
  }
9938
10021
 
9939
10022
  // hoist static sub-trees out
9940
- function genStatic (el, state, once$$1) {
10023
+ function genStatic (el, state) {
9941
10024
  el.staticProcessed = true;
9942
10025
  state.staticRenderFns.push(("with(this){return " + (genElement(el, state)) + "}"));
9943
- return ("_m(" + (state.staticRenderFns.length - 1) + "," + (el.staticInFor ? 'true' : 'false') + "," + (once$$1 ? 'true' : 'false') + ")")
10026
+ return ("_m(" + (state.staticRenderFns.length - 1) + (el.staticInFor ? ',true' : '') + ")")
9944
10027
  }
9945
10028
 
9946
10029
  // v-once
@@ -9966,7 +10049,7 @@ function genOnce (el, state) {
9966
10049
  }
9967
10050
  return ("_o(" + (genElement(el, state)) + "," + (state.onceId++) + "," + key + ")")
9968
10051
  } else {
9969
- return genStatic(el, state, true)
10052
+ return genStatic(el, state)
9970
10053
  }
9971
10054
  }
9972
10055
 
@@ -10306,7 +10389,10 @@ function genProps (props) {
10306
10389
  var res = '';
10307
10390
  for (var i = 0; i < props.length; i++) {
10308
10391
  var prop = props[i];
10309
- res += "\"" + (prop.name) + "\":" + (transformSpecialNewlines(prop.value)) + ",";
10392
+ /* istanbul ignore if */
10393
+ {
10394
+ res += "\"" + (prop.name) + "\":" + (transformSpecialNewlines(prop.value)) + ",";
10395
+ }
10310
10396
  }
10311
10397
  return res.slice(0, -1)
10312
10398
  }
@@ -10546,7 +10632,7 @@ function createCompilerCreator (baseCompile) {
10546
10632
  // merge custom directives
10547
10633
  if (options.directives) {
10548
10634
  finalOptions.directives = extend(
10549
- Object.create(baseOptions.directives),
10635
+ Object.create(baseOptions.directives || null),
10550
10636
  options.directives
10551
10637
  );
10552
10638
  }
@@ -10584,7 +10670,9 @@ var createCompiler = createCompilerCreator(function baseCompile (
10584
10670
  options
10585
10671
  ) {
10586
10672
  var ast = parse(template.trim(), options);
10587
- optimize(ast, options);
10673
+ if (options.optimize !== false) {
10674
+ optimize(ast, options);
10675
+ }
10588
10676
  var code = generate(ast, options);
10589
10677
  return {
10590
10678
  ast: ast,