@vue/runtime-dom 3.1.0-beta.5 → 3.1.1

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.
@@ -334,7 +334,7 @@ var VueRuntimeDOM = (function (exports) {
334
334
  function createReactiveEffect(fn, options) {
335
335
  const effect = function reactiveEffect() {
336
336
  if (!effect.active) {
337
- return options.scheduler ? undefined : fn();
337
+ return fn();
338
338
  }
339
339
  if (!effectStack.includes(effect)) {
340
340
  cleanup(effect);
@@ -1560,7 +1560,7 @@ var VueRuntimeDOM = (function (exports) {
1560
1560
  try {
1561
1561
  for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
1562
1562
  const job = queue[flushIndex];
1563
- if (job) {
1563
+ if (job && job.active !== false) {
1564
1564
  if (true && checkRecursiveUpdates(seen, job)) {
1565
1565
  continue;
1566
1566
  }
@@ -1742,7 +1742,7 @@ var VueRuntimeDOM = (function (exports) {
1742
1742
  exports.devtools.emit("app:init" /* APP_INIT */, app, version, {
1743
1743
  Fragment,
1744
1744
  Text,
1745
- Comment,
1745
+ Comment: Comment$1,
1746
1746
  Static
1747
1747
  });
1748
1748
  }
@@ -2072,7 +2072,7 @@ var VueRuntimeDOM = (function (exports) {
2072
2072
  warnCount[dupKey] = 0;
2073
2073
  const { message, link } = deprecationData[key];
2074
2074
  warn(`(deprecation ${key}) ${typeof message === 'function' ? message(...args) : message}${link ? `\n Details: ${link}` : ``}`);
2075
- if (!isCompatEnabled(key, instance)) {
2075
+ if (!isCompatEnabled(key, instance, true)) {
2076
2076
  console.error(`^ The above deprecation's compat behavior is disabled and will likely ` +
2077
2077
  `lead to runtime errors.`);
2078
2078
  }
@@ -2179,8 +2179,10 @@ var VueRuntimeDOM = (function (exports) {
2179
2179
  }
2180
2180
  }
2181
2181
  function normalizeEmitsOptions(comp, appContext, asMixin = false) {
2182
- if (!appContext.deopt && comp.__emits !== undefined) {
2183
- return comp.__emits;
2182
+ const cache = appContext.emitsCache;
2183
+ const cached = cache.get(comp);
2184
+ if (cached !== undefined) {
2185
+ return cached;
2184
2186
  }
2185
2187
  const raw = comp.emits;
2186
2188
  let normalized = {};
@@ -2205,7 +2207,8 @@ var VueRuntimeDOM = (function (exports) {
2205
2207
  }
2206
2208
  }
2207
2209
  if (!raw && !hasExtends) {
2208
- return (comp.__emits = null);
2210
+ cache.set(comp, null);
2211
+ return null;
2209
2212
  }
2210
2213
  if (isArray(raw)) {
2211
2214
  raw.forEach(key => (normalized[key] = null));
@@ -2213,7 +2216,8 @@ var VueRuntimeDOM = (function (exports) {
2213
2216
  else {
2214
2217
  extend(normalized, raw);
2215
2218
  }
2216
- return (comp.__emits = normalized);
2219
+ cache.set(comp, normalized);
2220
+ return normalized;
2217
2221
  }
2218
2222
  // Check if an incoming prop key is a declared emit event listener.
2219
2223
  // e.g. With `emits: { click: null }`, props named `onClick` and `onclick` are
@@ -2323,7 +2327,7 @@ var VueRuntimeDOM = (function (exports) {
2323
2327
  accessedAttrs = true;
2324
2328
  }
2325
2329
  function renderComponentRoot(instance) {
2326
- const { type: Component, vnode, proxy, withProxy, props, propsOptions: [propsOptions], slots, attrs, emit, render, renderCache, data, setupState, ctx } = instance;
2330
+ const { type: Component, vnode, proxy, withProxy, props, propsOptions: [propsOptions], slots, attrs, emit, render, renderCache, data, setupState, ctx, inheritAttrs } = instance;
2327
2331
  let result;
2328
2332
  const prev = setCurrentRenderingInstance(instance);
2329
2333
  {
@@ -2372,7 +2376,7 @@ var VueRuntimeDOM = (function (exports) {
2372
2376
  ;
2373
2377
  [root, setRoot] = getChildRoot(result);
2374
2378
  }
2375
- if (fallthroughAttrs && Component.inheritAttrs !== false) {
2379
+ if (fallthroughAttrs && inheritAttrs !== false) {
2376
2380
  const keys = Object.keys(fallthroughAttrs);
2377
2381
  const { shapeFlag } = root;
2378
2382
  if (keys.length) {
@@ -2387,7 +2391,7 @@ var VueRuntimeDOM = (function (exports) {
2387
2391
  }
2388
2392
  root = cloneVNode(root, fallthroughAttrs);
2389
2393
  }
2390
- else if (true && !accessedAttrs && root.type !== Comment) {
2394
+ else if (true && !accessedAttrs && root.type !== Comment$1) {
2391
2395
  const allAttrs = Object.keys(attrs);
2392
2396
  const eventAttrs = [];
2393
2397
  const extraAttrs = [];
@@ -2453,7 +2457,7 @@ var VueRuntimeDOM = (function (exports) {
2453
2457
  catch (err) {
2454
2458
  blockStack.length = 0;
2455
2459
  handleError(err, instance, 1 /* RENDER_FUNCTION */);
2456
- result = createVNode(Comment);
2460
+ result = createVNode(Comment$1);
2457
2461
  }
2458
2462
  setCurrentRenderingInstance(prev);
2459
2463
  return result;
@@ -2492,7 +2496,7 @@ var VueRuntimeDOM = (function (exports) {
2492
2496
  const child = children[i];
2493
2497
  if (isVNode(child)) {
2494
2498
  // ignore user comment
2495
- if (child.type !== Comment || child.children === 'v-if') {
2499
+ if (child.type !== Comment$1 || child.children === 'v-if') {
2496
2500
  if (singleRoot) {
2497
2501
  // has more than 1 non-comment child, return now
2498
2502
  return;
@@ -2529,7 +2533,7 @@ var VueRuntimeDOM = (function (exports) {
2529
2533
  const isElementRoot = (vnode) => {
2530
2534
  return (vnode.shapeFlag & 6 /* COMPONENT */ ||
2531
2535
  vnode.shapeFlag & 1 /* ELEMENT */ ||
2532
- vnode.type === Comment // potential v-if branch switch
2536
+ vnode.type === Comment$1 // potential v-if branch switch
2533
2537
  );
2534
2538
  };
2535
2539
  function shouldUpdateComponent(prevVNode, nextVNode, optimized) {
@@ -2635,7 +2639,8 @@ var VueRuntimeDOM = (function (exports) {
2635
2639
  }
2636
2640
  },
2637
2641
  hydrate: hydrateSuspense,
2638
- create: createSuspenseBoundary
2642
+ create: createSuspenseBoundary,
2643
+ normalize: normalizeSuspenseChildren
2639
2644
  };
2640
2645
  // Force-casted public typing for h and TSX props inference
2641
2646
  const Suspense = (SuspenseImpl
@@ -2980,24 +2985,29 @@ var VueRuntimeDOM = (function (exports) {
2980
2985
  }
2981
2986
  function normalizeSuspenseChildren(vnode) {
2982
2987
  const { shapeFlag, children } = vnode;
2983
- let content;
2984
- let fallback;
2985
- if (shapeFlag & 32 /* SLOTS_CHILDREN */) {
2986
- content = normalizeSuspenseSlot(children.default);
2987
- fallback = normalizeSuspenseSlot(children.fallback);
2988
- }
2989
- else {
2990
- content = normalizeSuspenseSlot(children);
2991
- fallback = normalizeVNode(null);
2992
- }
2993
- return {
2994
- content,
2995
- fallback
2996
- };
2988
+ const isSlotChildren = shapeFlag & 32 /* SLOTS_CHILDREN */;
2989
+ vnode.ssContent = normalizeSuspenseSlot(isSlotChildren ? children.default : children);
2990
+ vnode.ssFallback = isSlotChildren
2991
+ ? normalizeSuspenseSlot(children.fallback)
2992
+ : createVNode(Comment);
2997
2993
  }
2998
2994
  function normalizeSuspenseSlot(s) {
2995
+ let block;
2999
2996
  if (isFunction(s)) {
2997
+ const isCompiledSlot = s._c;
2998
+ if (isCompiledSlot) {
2999
+ // disableTracking: false
3000
+ // allow block tracking for compiled slots
3001
+ // (see ./componentRenderContext.ts)
3002
+ s._d = false;
3003
+ openBlock();
3004
+ }
3000
3005
  s = s();
3006
+ if (isCompiledSlot) {
3007
+ s._d = true;
3008
+ block = currentBlock;
3009
+ closeBlock();
3010
+ }
3001
3011
  }
3002
3012
  if (isArray(s)) {
3003
3013
  const singleChild = filterSingleRoot(s);
@@ -3006,7 +3016,11 @@ var VueRuntimeDOM = (function (exports) {
3006
3016
  }
3007
3017
  s = singleChild;
3008
3018
  }
3009
- return normalizeVNode(s);
3019
+ s = normalizeVNode(s);
3020
+ if (block) {
3021
+ s.dynamicChildren = block.filter(c => c !== s);
3022
+ }
3023
+ return s;
3010
3024
  }
3011
3025
  function queueEffectWithSuspense(fn, suspense) {
3012
3026
  if (suspense && suspense.pendingBranch) {
@@ -3211,7 +3225,7 @@ var VueRuntimeDOM = (function (exports) {
3211
3225
  job.allowRecurse = !!cb;
3212
3226
  let scheduler;
3213
3227
  if (flush === 'sync') {
3214
- scheduler = job;
3228
+ scheduler = job; // the scheduler function gets called directly
3215
3229
  }
3216
3230
  else if (flush === 'post') {
3217
3231
  scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);
@@ -3287,7 +3301,9 @@ var VueRuntimeDOM = (function (exports) {
3287
3301
  };
3288
3302
  }
3289
3303
  function traverse(value, seen = new Set()) {
3290
- if (!isObject(value) || seen.has(value)) {
3304
+ if (!isObject(value) ||
3305
+ seen.has(value) ||
3306
+ value["__v_skip" /* SKIP */]) {
3291
3307
  return value;
3292
3308
  }
3293
3309
  seen.add(value);
@@ -3401,7 +3417,7 @@ var VueRuntimeDOM = (function (exports) {
3401
3417
  }
3402
3418
  // handle mode
3403
3419
  if (oldInnerChild &&
3404
- oldInnerChild.type !== Comment &&
3420
+ oldInnerChild.type !== Comment$1 &&
3405
3421
  (!isSameVNodeType(innerChild, oldInnerChild) || transitionKeyChanged)) {
3406
3422
  const leavingHooks = resolveTransitionHooks(oldInnerChild, rawProps, state, instance);
3407
3423
  // update old tree's hooks in case of dynamic transition
@@ -3416,7 +3432,7 @@ var VueRuntimeDOM = (function (exports) {
3416
3432
  };
3417
3433
  return emptyPlaceholder(child);
3418
3434
  }
3419
- else if (mode === 'in-out' && innerChild.type !== Comment) {
3435
+ else if (mode === 'in-out' && innerChild.type !== Comment$1) {
3420
3436
  leavingHooks.delayLeave = (el, earlyRemove, delayedLeave) => {
3421
3437
  const leavingVNodesCache = getLeavingNodesForType(state, oldInnerChild);
3422
3438
  leavingVNodesCache[String(oldInnerChild.key)] = oldInnerChild;
@@ -3608,7 +3624,7 @@ var VueRuntimeDOM = (function (exports) {
3608
3624
  ret = ret.concat(getTransitionRawChildren(child.children, keepComment));
3609
3625
  }
3610
3626
  // comment placeholders should be skipped, e.g. v-if
3611
- else if (keepComment || child.type !== Comment) {
3627
+ else if (keepComment || child.type !== Comment$1) {
3612
3628
  ret.push(child);
3613
3629
  }
3614
3630
  }
@@ -4106,75 +4122,6 @@ var VueRuntimeDOM = (function (exports) {
4106
4122
  injectHook("ec" /* ERROR_CAPTURED */, hook, target);
4107
4123
  }
4108
4124
 
4109
- const COMPONENTS = 'components';
4110
- const DIRECTIVES = 'directives';
4111
- /**
4112
- * @private
4113
- */
4114
- function resolveComponent(name, maybeSelfReference) {
4115
- return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
4116
- }
4117
- const NULL_DYNAMIC_COMPONENT = Symbol();
4118
- /**
4119
- * @private
4120
- */
4121
- function resolveDynamicComponent(component) {
4122
- if (isString(component)) {
4123
- return resolveAsset(COMPONENTS, component, false) || component;
4124
- }
4125
- else {
4126
- // invalid types will fallthrough to createVNode and raise warning
4127
- return (component || NULL_DYNAMIC_COMPONENT);
4128
- }
4129
- }
4130
- /**
4131
- * @private
4132
- */
4133
- function resolveDirective(name) {
4134
- return resolveAsset(DIRECTIVES, name);
4135
- }
4136
- // implementation
4137
- function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
4138
- const instance = currentRenderingInstance || currentInstance;
4139
- if (instance) {
4140
- const Component = instance.type;
4141
- // explicit self name has highest priority
4142
- if (type === COMPONENTS) {
4143
- const selfName = getComponentName(Component);
4144
- if (selfName &&
4145
- (selfName === name ||
4146
- selfName === camelize(name) ||
4147
- selfName === capitalize(camelize(name)))) {
4148
- return Component;
4149
- }
4150
- }
4151
- const res =
4152
- // local registration
4153
- // check instance[type] first for components with mixin or extends.
4154
- resolve(instance[type] || Component[type], name) ||
4155
- // global registration
4156
- resolve(instance.appContext[type], name);
4157
- if (!res && maybeSelfReference) {
4158
- // fallback to implicit self-reference
4159
- return Component;
4160
- }
4161
- if (warnMissing && !res) {
4162
- warn(`Failed to resolve ${type.slice(0, -1)}: ${name}`);
4163
- }
4164
- return res;
4165
- }
4166
- else {
4167
- warn(`resolve${capitalize(type.slice(0, -1))} ` +
4168
- `can only be used in render() or setup().`);
4169
- }
4170
- }
4171
- function resolve(registry, name) {
4172
- return (registry &&
4173
- (registry[name] ||
4174
- registry[camelize(name)] ||
4175
- registry[capitalize(camelize(name))]));
4176
- }
4177
-
4178
4125
  function createDuplicateChecker() {
4179
4126
  const cache = Object.create(null);
4180
4127
  return (type, key) => {
@@ -4187,38 +4134,26 @@ var VueRuntimeDOM = (function (exports) {
4187
4134
  };
4188
4135
  }
4189
4136
  let shouldCacheAccess = true;
4190
- function applyOptions(instance, options, deferredData = [], deferredWatch = [], deferredProvide = [], asMixin = false) {
4137
+ function applyOptions(instance) {
4138
+ const options = resolveMergedOptions(instance);
4139
+ const publicThis = instance.proxy;
4140
+ const ctx = instance.ctx;
4141
+ // do not cache property access on public proxy during state initialization
4142
+ shouldCacheAccess = false;
4143
+ // call beforeCreate first before accessing other options since
4144
+ // the hook may mutate resolved options (#2791)
4145
+ if (options.beforeCreate) {
4146
+ callHook(options.beforeCreate, instance, "bc" /* BEFORE_CREATE */);
4147
+ }
4191
4148
  const {
4192
- // composition
4193
- mixins, extends: extendsOptions,
4194
4149
  // state
4195
4150
  data: dataOptions, computed: computedOptions, methods, watch: watchOptions, provide: provideOptions, inject: injectOptions,
4196
4151
  // lifecycle
4197
- beforeMount, mounted, beforeUpdate, updated, activated, deactivated, beforeDestroy, beforeUnmount, destroyed, unmounted, render, renderTracked, renderTriggered, errorCaptured, serverPrefetch,
4152
+ created, beforeMount, mounted, beforeUpdate, updated, activated, deactivated, beforeDestroy, beforeUnmount, destroyed, unmounted, render, renderTracked, renderTriggered, errorCaptured, serverPrefetch,
4198
4153
  // public API
4199
- expose } = options;
4200
- const publicThis = instance.proxy;
4201
- const ctx = instance.ctx;
4202
- const globalMixins = instance.appContext.mixins;
4203
- if (asMixin && render && instance.render === NOOP) {
4204
- instance.render = render;
4205
- }
4206
- // applyOptions is called non-as-mixin once per instance
4207
- if (!asMixin) {
4208
- shouldCacheAccess = false;
4209
- callSyncHook('beforeCreate', "bc" /* BEFORE_CREATE */, options, instance, globalMixins);
4210
- shouldCacheAccess = true;
4211
- // global mixins are applied first
4212
- applyMixins(instance, globalMixins, deferredData, deferredWatch, deferredProvide);
4213
- }
4214
- // extending a base component...
4215
- if (extendsOptions) {
4216
- applyOptions(instance, extendsOptions, deferredData, deferredWatch, deferredProvide, true);
4217
- }
4218
- // local mixins
4219
- if (mixins) {
4220
- applyMixins(instance, mixins, deferredData, deferredWatch, deferredProvide);
4221
- }
4154
+ expose, inheritAttrs,
4155
+ // assets
4156
+ components, directives, filters } = options;
4222
4157
  const checkDuplicateProperties = createDuplicateChecker() ;
4223
4158
  {
4224
4159
  const [propsOptions] = instance.propsOptions;
@@ -4262,33 +4197,40 @@ var VueRuntimeDOM = (function (exports) {
4262
4197
  }
4263
4198
  }
4264
4199
  }
4265
- if (!asMixin) {
4266
- if (deferredData.length) {
4267
- deferredData.forEach(dataFn => resolveData(instance, dataFn, publicThis));
4200
+ if (dataOptions) {
4201
+ if (!isFunction(dataOptions)) {
4202
+ warn(`The data option must be a function. ` +
4203
+ `Plain object usage is no longer supported.`);
4268
4204
  }
4269
- if (dataOptions) {
4270
- // @ts-ignore dataOptions is not fully type safe
4271
- resolveData(instance, dataOptions, publicThis);
4205
+ const data = dataOptions.call(publicThis, publicThis);
4206
+ if (isPromise(data)) {
4207
+ warn(`data() returned a Promise - note data() cannot be async; If you ` +
4208
+ `intend to perform data fetching before component renders, use ` +
4209
+ `async setup() + <Suspense>.`);
4272
4210
  }
4273
- {
4274
- const rawData = toRaw(instance.data);
4275
- for (const key in rawData) {
4276
- checkDuplicateProperties("Data" /* DATA */, key);
4277
- // expose data on ctx during dev
4278
- if (key[0] !== '$' && key[0] !== '_') {
4279
- Object.defineProperty(ctx, key, {
4280
- configurable: true,
4281
- enumerable: true,
4282
- get: () => rawData[key],
4283
- set: NOOP
4284
- });
4211
+ if (!isObject(data)) {
4212
+ warn(`data() should return an object.`);
4213
+ }
4214
+ else {
4215
+ instance.data = reactive(data);
4216
+ {
4217
+ for (const key in data) {
4218
+ checkDuplicateProperties("Data" /* DATA */, key);
4219
+ // expose data on ctx during dev
4220
+ if (key[0] !== '$' && key[0] !== '_') {
4221
+ Object.defineProperty(ctx, key, {
4222
+ configurable: true,
4223
+ enumerable: true,
4224
+ get: () => data[key],
4225
+ set: NOOP
4226
+ });
4227
+ }
4285
4228
  }
4286
4229
  }
4287
4230
  }
4288
4231
  }
4289
- else if (dataOptions) {
4290
- deferredData.push(dataOptions);
4291
- }
4232
+ // state initialization complete at this point - start caching access
4233
+ shouldCacheAccess = true;
4292
4234
  if (computedOptions) {
4293
4235
  for (const key in computedOptions) {
4294
4236
  const opt = computedOptions[key];
@@ -4322,42 +4264,26 @@ var VueRuntimeDOM = (function (exports) {
4322
4264
  }
4323
4265
  }
4324
4266
  if (watchOptions) {
4325
- deferredWatch.push(watchOptions);
4326
- }
4327
- if (!asMixin && deferredWatch.length) {
4328
- deferredWatch.forEach(watchOptions => {
4329
- for (const key in watchOptions) {
4330
- createWatcher(watchOptions[key], ctx, publicThis, key);
4331
- }
4332
- });
4267
+ for (const key in watchOptions) {
4268
+ createWatcher(watchOptions[key], ctx, publicThis, key);
4269
+ }
4333
4270
  }
4334
4271
  if (provideOptions) {
4335
- deferredProvide.push(provideOptions);
4336
- }
4337
- if (!asMixin && deferredProvide.length) {
4338
- deferredProvide.forEach(provideOptions => {
4339
- const provides = isFunction(provideOptions)
4340
- ? provideOptions.call(publicThis)
4341
- : provideOptions;
4342
- Reflect.ownKeys(provides).forEach(key => {
4343
- provide(key, provides[key]);
4344
- });
4272
+ const provides = isFunction(provideOptions)
4273
+ ? provideOptions.call(publicThis)
4274
+ : provideOptions;
4275
+ Reflect.ownKeys(provides).forEach(key => {
4276
+ provide(key, provides[key]);
4345
4277
  });
4346
4278
  }
4347
- // asset options.
4348
- // To reduce memory usage, only components with mixins or extends will have
4349
- // resolved asset registry attached to instance.
4350
- if (asMixin) {
4351
- resolveInstanceAssets(instance, options, COMPONENTS);
4352
- resolveInstanceAssets(instance, options, DIRECTIVES);
4353
- }
4354
- // lifecycle options
4355
- if (!asMixin) {
4356
- callSyncHook('created', "c" /* CREATED */, options, instance, globalMixins);
4279
+ if (created) {
4280
+ callHook(created, instance, "c" /* CREATED */);
4357
4281
  }
4358
4282
  function registerLifecycleHook(register, hook) {
4359
- // Array lifecycle hooks are only present in the compat build
4360
- if (hook) {
4283
+ if (isArray(hook)) {
4284
+ hook.forEach(_hook => register(_hook.bind(publicThis)));
4285
+ }
4286
+ else if (hook) {
4361
4287
  register(hook.bind(publicThis));
4362
4288
  }
4363
4289
  }
@@ -4374,105 +4300,57 @@ var VueRuntimeDOM = (function (exports) {
4374
4300
  registerLifecycleHook(onUnmounted, unmounted);
4375
4301
  registerLifecycleHook(onServerPrefetch, serverPrefetch);
4376
4302
  if (isArray(expose)) {
4377
- if (!asMixin) {
4378
- if (expose.length) {
4379
- const exposed = instance.exposed || (instance.exposed = proxyRefs({}));
4380
- expose.forEach(key => {
4381
- exposed[key] = toRef(publicThis, key);
4382
- });
4383
- }
4384
- else if (!instance.exposed) {
4385
- instance.exposed = EMPTY_OBJ;
4386
- }
4303
+ if (expose.length) {
4304
+ const exposed = instance.exposed || (instance.exposed = proxyRefs({}));
4305
+ expose.forEach(key => {
4306
+ exposed[key] = toRef(publicThis, key);
4307
+ });
4387
4308
  }
4388
- else {
4389
- warn(`The \`expose\` option is ignored when used in mixins.`);
4309
+ else if (!instance.exposed) {
4310
+ instance.exposed = EMPTY_OBJ;
4390
4311
  }
4391
4312
  }
4392
- }
4393
- function resolveInstanceAssets(instance, mixin, type) {
4394
- if (mixin[type]) {
4395
- extend(instance[type] ||
4396
- (instance[type] = extend({}, instance.type[type])), mixin[type]);
4313
+ // options that are handled when creating the instance but also need to be
4314
+ // applied from mixins
4315
+ if (render && instance.render === NOOP) {
4316
+ instance.render = render;
4317
+ }
4318
+ if (inheritAttrs != null) {
4319
+ instance.inheritAttrs = inheritAttrs;
4397
4320
  }
4321
+ // asset options.
4322
+ if (components)
4323
+ instance.components = components;
4324
+ if (directives)
4325
+ instance.directives = directives;
4398
4326
  }
4399
4327
  function resolveInjections(injectOptions, ctx, checkDuplicateProperties = NOOP) {
4400
4328
  if (isArray(injectOptions)) {
4401
- for (let i = 0; i < injectOptions.length; i++) {
4402
- const key = injectOptions[i];
4403
- ctx[key] = inject(key);
4404
- {
4405
- checkDuplicateProperties("Inject" /* INJECT */, key);
4406
- }
4407
- }
4329
+ injectOptions = normalizeInject(injectOptions);
4408
4330
  }
4409
- else {
4410
- for (const key in injectOptions) {
4411
- const opt = injectOptions[key];
4412
- if (isObject(opt)) {
4331
+ for (const key in injectOptions) {
4332
+ const opt = injectOptions[key];
4333
+ if (isObject(opt)) {
4334
+ if ('default' in opt) {
4413
4335
  ctx[key] = inject(opt.from || key, opt.default, true /* treat default function as factory */);
4414
4336
  }
4415
4337
  else {
4416
- ctx[key] = inject(opt);
4417
- }
4418
- {
4419
- checkDuplicateProperties("Inject" /* INJECT */, key);
4338
+ ctx[key] = inject(opt.from || key);
4420
4339
  }
4421
4340
  }
4422
- }
4423
- }
4424
- function callSyncHook(name, type, options, instance, globalMixins) {
4425
- for (let i = 0; i < globalMixins.length; i++) {
4426
- callHookWithMixinAndExtends(name, type, globalMixins[i], instance);
4427
- }
4428
- callHookWithMixinAndExtends(name, type, options, instance);
4429
- }
4430
- function callHookWithMixinAndExtends(name, type, options, instance) {
4431
- const { extends: base, mixins } = options;
4432
- const selfHook = options[name];
4433
- if (base) {
4434
- callHookWithMixinAndExtends(name, type, base, instance);
4435
- }
4436
- if (mixins) {
4437
- for (let i = 0; i < mixins.length; i++) {
4438
- callHookWithMixinAndExtends(name, type, mixins[i], instance);
4341
+ else {
4342
+ ctx[key] = inject(opt);
4439
4343
  }
4440
- }
4441
- if (selfHook) {
4442
- callWithAsyncErrorHandling(selfHook.bind(instance.proxy), instance, type);
4443
- }
4444
- }
4445
- function applyMixins(instance, mixins, deferredData, deferredWatch, deferredProvide) {
4446
- for (let i = 0; i < mixins.length; i++) {
4447
- applyOptions(instance, mixins[i], deferredData, deferredWatch, deferredProvide, true);
4448
- }
4449
- }
4450
- function resolveData(instance, dataFn, publicThis) {
4451
- if (!isFunction(dataFn)) {
4452
- warn(`The data option must be a function. ` +
4453
- `Plain object usage is no longer supported.`);
4454
- }
4455
- shouldCacheAccess = false;
4456
- const data = dataFn.call(publicThis, publicThis);
4457
- shouldCacheAccess = true;
4458
- if (isPromise(data)) {
4459
- warn(`data() returned a Promise - note data() cannot be async; If you ` +
4460
- `intend to perform data fetching before component renders, use ` +
4461
- `async setup() + <Suspense>.`);
4462
- }
4463
- if (!isObject(data)) {
4464
- warn(`data() should return an object.`);
4465
- }
4466
- else if (instance.data === EMPTY_OBJ) {
4467
- instance.data = reactive(data);
4468
- }
4469
- else {
4470
- // existing data: this is a mixin or extends.
4471
4344
  {
4472
- extend(instance.data, data);
4345
+ checkDuplicateProperties("Inject" /* INJECT */, key);
4473
4346
  }
4474
4347
  }
4475
4348
  }
4349
+ function callHook(hook, instance, type) {
4350
+ callWithAsyncErrorHandling(isArray(hook)
4351
+ ? hook.map(h => h.bind(instance.proxy))
4352
+ : hook.bind(instance.proxy), instance, type);
4353
+ }
4476
4354
  function createWatcher(raw, ctx, publicThis, key) {
4477
4355
  const getter = key.includes('.')
4478
4356
  ? createPathGetter(publicThis, key)
@@ -4509,33 +4387,115 @@ var VueRuntimeDOM = (function (exports) {
4509
4387
  warn(`Invalid watch option: "${key}"`, raw);
4510
4388
  }
4511
4389
  }
4390
+ /**
4391
+ * Resolve merged options and cache it on the component.
4392
+ * This is done only once per-component since the merging does not involve
4393
+ * instances.
4394
+ */
4512
4395
  function resolveMergedOptions(instance) {
4513
- const raw = instance.type;
4514
- const { __merged, mixins, extends: extendsOptions } = raw;
4515
- if (__merged)
4516
- return __merged;
4517
- const globalMixins = instance.appContext.mixins;
4518
- if (!globalMixins.length && !mixins && !extendsOptions)
4519
- return raw;
4520
- const options = {};
4521
- globalMixins.forEach(m => mergeOptions(options, m, instance));
4522
- mergeOptions(options, raw, instance);
4523
- return (raw.__merged = options);
4524
- }
4525
- function mergeOptions(to, from, instance, strats = instance && instance.appContext.config.optionMergeStrategies) {
4396
+ const base = instance.type;
4397
+ const { mixins, extends: extendsOptions } = base;
4398
+ const { mixins: globalMixins, optionsCache: cache, config: { optionMergeStrategies } } = instance.appContext;
4399
+ const cached = cache.get(base);
4400
+ let resolved;
4401
+ if (cached) {
4402
+ resolved = cached;
4403
+ }
4404
+ else if (!globalMixins.length && !mixins && !extendsOptions) {
4405
+ {
4406
+ resolved = base;
4407
+ }
4408
+ }
4409
+ else {
4410
+ resolved = {};
4411
+ if (globalMixins.length) {
4412
+ globalMixins.forEach(m => mergeOptions(resolved, m, optionMergeStrategies, true));
4413
+ }
4414
+ mergeOptions(resolved, base, optionMergeStrategies);
4415
+ }
4416
+ cache.set(base, resolved);
4417
+ return resolved;
4418
+ }
4419
+ function mergeOptions(to, from, strats, asMixin = false) {
4526
4420
  const { mixins, extends: extendsOptions } = from;
4527
- extendsOptions && mergeOptions(to, extendsOptions, instance, strats);
4528
- mixins &&
4529
- mixins.forEach((m) => mergeOptions(to, m, instance, strats));
4421
+ if (extendsOptions) {
4422
+ mergeOptions(to, extendsOptions, strats, true);
4423
+ }
4424
+ if (mixins) {
4425
+ mixins.forEach((m) => mergeOptions(to, m, strats, true));
4426
+ }
4530
4427
  for (const key in from) {
4531
- if (strats && hasOwn(strats, key)) {
4532
- to[key] = strats[key](to[key], from[key], instance && instance.proxy, key);
4428
+ if (asMixin && key === 'expose') {
4429
+ warn(`"expose" option is ignored when declared in mixins or extends. ` +
4430
+ `It should only be declared in the base component itself.`);
4533
4431
  }
4534
4432
  else {
4535
- to[key] = from[key];
4433
+ const strat = internalOptionMergeStrats[key] || (strats && strats[key]);
4434
+ to[key] = strat ? strat(to[key], from[key]) : from[key];
4536
4435
  }
4537
4436
  }
4538
4437
  return to;
4438
+ }
4439
+ const internalOptionMergeStrats = {
4440
+ data: mergeDataFn,
4441
+ props: mergeObjectOptions,
4442
+ emits: mergeObjectOptions,
4443
+ // objects
4444
+ methods: mergeObjectOptions,
4445
+ computed: mergeObjectOptions,
4446
+ // lifecycle
4447
+ beforeCreate: mergeHook,
4448
+ created: mergeHook,
4449
+ beforeMount: mergeHook,
4450
+ mounted: mergeHook,
4451
+ beforeUpdate: mergeHook,
4452
+ updated: mergeHook,
4453
+ beforeDestroy: mergeHook,
4454
+ destroyed: mergeHook,
4455
+ activated: mergeHook,
4456
+ deactivated: mergeHook,
4457
+ errorCaptured: mergeHook,
4458
+ serverPrefetch: mergeHook,
4459
+ // assets
4460
+ components: mergeObjectOptions,
4461
+ directives: mergeObjectOptions,
4462
+ // watch has special merge behavior in v2, but isn't actually needed in v3.
4463
+ // since we are only exposing these for compat and nobody should be relying
4464
+ // on the watch-specific behavior, just expose the object merge strat.
4465
+ watch: mergeObjectOptions,
4466
+ // provide / inject
4467
+ provide: mergeDataFn,
4468
+ inject: mergeInject
4469
+ };
4470
+ function mergeDataFn(to, from) {
4471
+ if (!from) {
4472
+ return to;
4473
+ }
4474
+ if (!to) {
4475
+ return from;
4476
+ }
4477
+ return function mergedDataFn() {
4478
+ return (extend)(isFunction(to) ? to.call(this, this) : to, isFunction(from) ? from.call(this, this) : from);
4479
+ };
4480
+ }
4481
+ function mergeInject(to, from) {
4482
+ return mergeObjectOptions(normalizeInject(to), normalizeInject(from));
4483
+ }
4484
+ function normalizeInject(raw) {
4485
+ if (isArray(raw)) {
4486
+ const res = {};
4487
+ for (let i = 0; i < raw.length; i++) {
4488
+ res[raw[i]] = raw[i];
4489
+ }
4490
+ return res;
4491
+ }
4492
+ return raw;
4493
+ }
4494
+ function mergeHook(to, from) {
4495
+ return to ? [...new Set([].concat(to, from))] : from;
4496
+ }
4497
+ function mergeObjectOptions(to, from) {
4498
+ return to ? extend(extend(Object.create(null), to), from) : from;
4539
4499
  }
4540
4500
 
4541
4501
  function initProps(instance, rawProps, isStateful, // result of bitwise flag comparison
@@ -4739,8 +4699,10 @@ var VueRuntimeDOM = (function (exports) {
4739
4699
  return value;
4740
4700
  }
4741
4701
  function normalizePropsOptions(comp, appContext, asMixin = false) {
4742
- if (!appContext.deopt && comp.__props) {
4743
- return comp.__props;
4702
+ const cache = appContext.propsCache;
4703
+ const cached = cache.get(comp);
4704
+ if (cached) {
4705
+ return cached;
4744
4706
  }
4745
4707
  const raw = comp.props;
4746
4708
  const normalized = {};
@@ -4766,7 +4728,8 @@ var VueRuntimeDOM = (function (exports) {
4766
4728
  }
4767
4729
  }
4768
4730
  if (!raw && !hasExtends) {
4769
- return (comp.__props = EMPTY_ARR);
4731
+ cache.set(comp, EMPTY_ARR);
4732
+ return EMPTY_ARR;
4770
4733
  }
4771
4734
  if (isArray(raw)) {
4772
4735
  for (let i = 0; i < raw.length; i++) {
@@ -4803,7 +4766,9 @@ var VueRuntimeDOM = (function (exports) {
4803
4766
  }
4804
4767
  }
4805
4768
  }
4806
- return (comp.__props = [normalized, needCastKeys]);
4769
+ const res = [normalized, needCastKeys];
4770
+ cache.set(comp, res);
4771
+ return res;
4807
4772
  }
4808
4773
  function validatePropName(key) {
4809
4774
  if (key[0] !== '$') {
@@ -5136,12 +5101,16 @@ var VueRuntimeDOM = (function (exports) {
5136
5101
  }
5137
5102
  let hook = binding.dir[name];
5138
5103
  if (hook) {
5104
+ // disable tracking inside all lifecycle hooks
5105
+ // since they can potentially be called inside effects.
5106
+ pauseTracking();
5139
5107
  callWithAsyncErrorHandling(hook, instance, 8 /* DIRECTIVE_HOOK */, [
5140
5108
  vnode.el,
5141
5109
  binding,
5142
5110
  vnode,
5143
5111
  prevVNode
5144
5112
  ]);
5113
+ resetTracking();
5145
5114
  }
5146
5115
  }
5147
5116
  }
@@ -5161,7 +5130,10 @@ var VueRuntimeDOM = (function (exports) {
5161
5130
  mixins: [],
5162
5131
  components: {},
5163
5132
  directives: {},
5164
- provides: Object.create(null)
5133
+ provides: Object.create(null),
5134
+ optionsCache: new WeakMap(),
5135
+ propsCache: new WeakMap(),
5136
+ emitsCache: new WeakMap()
5165
5137
  };
5166
5138
  }
5167
5139
  let uid$1 = 0;
@@ -5211,11 +5183,6 @@ var VueRuntimeDOM = (function (exports) {
5211
5183
  {
5212
5184
  if (!context.mixins.includes(mixin)) {
5213
5185
  context.mixins.push(mixin);
5214
- // global mixin with props/emits de-optimizes props/emits
5215
- // normalization caching.
5216
- if (mixin.props || mixin.emits) {
5217
- context.deopt = true;
5218
- }
5219
5186
  }
5220
5187
  else {
5221
5188
  warn('Mixin has already been applied to target app' +
@@ -5358,7 +5325,7 @@ var VueRuntimeDOM = (function (exports) {
5358
5325
  nextNode = nextSibling(node);
5359
5326
  }
5360
5327
  break;
5361
- case Comment:
5328
+ case Comment$1:
5362
5329
  if (domType !== 8 /* COMMENT */ || isFragmentStart) {
5363
5330
  nextNode = onMismatch();
5364
5331
  }
@@ -5800,7 +5767,7 @@ var VueRuntimeDOM = (function (exports) {
5800
5767
  case Text:
5801
5768
  processText(n1, n2, container, anchor);
5802
5769
  break;
5803
- case Comment:
5770
+ case Comment$1:
5804
5771
  processCommentNode(n1, n2, container, anchor);
5805
5772
  break;
5806
5773
  case Static:
@@ -6095,15 +6062,18 @@ var VueRuntimeDOM = (function (exports) {
6095
6062
  const newVNode = newChildren[i];
6096
6063
  // Determine the container (parent element) for the patch.
6097
6064
  const container =
6098
- // - In the case of a Fragment, we need to provide the actual parent
6099
- // of the Fragment itself so it can move its children.
6100
- oldVNode.type === Fragment ||
6101
- // - In the case of different nodes, there is going to be a replacement
6102
- // which also requires the correct parent container
6103
- !isSameVNodeType(oldVNode, newVNode) ||
6104
- // - In the case of a component, it could contain anything.
6105
- oldVNode.shapeFlag & 6 /* COMPONENT */ ||
6106
- oldVNode.shapeFlag & 64 /* TELEPORT */
6065
+ // oldVNode may be an errored async setup() component inside Suspense
6066
+ // which will not have a mounted element
6067
+ oldVNode.el &&
6068
+ // - In the case of a Fragment, we need to provide the actual parent
6069
+ // of the Fragment itself so it can move its children.
6070
+ (oldVNode.type === Fragment ||
6071
+ // - In the case of different nodes, there is going to be a replacement
6072
+ // which also requires the correct parent container
6073
+ !isSameVNodeType(oldVNode, newVNode) ||
6074
+ // - In the case of a component, it could contain anything.
6075
+ oldVNode.shapeFlag & 6 /* COMPONENT */ ||
6076
+ oldVNode.shapeFlag & 64 /* TELEPORT */)
6107
6077
  ? hostParentNode(oldVNode.el)
6108
6078
  : // In other cases, the parent container is not actually used so we
6109
6079
  // just pass the block element here to avoid a DOM parentNode call.
@@ -6137,7 +6107,7 @@ var VueRuntimeDOM = (function (exports) {
6137
6107
  const fragmentStartAnchor = (n2.el = n1 ? n1.el : hostCreateText(''));
6138
6108
  const fragmentEndAnchor = (n2.anchor = n1 ? n1.anchor : hostCreateText(''));
6139
6109
  let { patchFlag, dynamicChildren, slotScopeIds: fragmentSlotScopeIds } = n2;
6140
- if (patchFlag > 0) {
6110
+ if (dynamicChildren) {
6141
6111
  optimized = true;
6142
6112
  }
6143
6113
  // check if this is a slot fragment with :slotted scope ids
@@ -6236,7 +6206,7 @@ var VueRuntimeDOM = (function (exports) {
6236
6206
  // Give it a placeholder if this is not hydration
6237
6207
  // TODO handle self-defined fallback
6238
6208
  if (!initialVNode.el) {
6239
- const placeholder = (instance.subTree = createVNode(Comment));
6209
+ const placeholder = (instance.subTree = createVNode(Comment$1));
6240
6210
  processCommentNode(null, placeholder, container, anchor);
6241
6211
  }
6242
6212
  return;
@@ -6983,7 +6953,7 @@ var VueRuntimeDOM = (function (exports) {
6983
6953
  }
6984
6954
  // also inherit for comment nodes, but not placeholders (e.g. v-if which
6985
6955
  // would have received .el during block patch)
6986
- if (c2.type === Comment && !c2.el) {
6956
+ if (c2.type === Comment$1 && !c2.el) {
6987
6957
  c2.el = c1.el;
6988
6958
  }
6989
6959
  }
@@ -7222,9 +7192,78 @@ var VueRuntimeDOM = (function (exports) {
7222
7192
  // Force-casted public typing for h and TSX props inference
7223
7193
  const Teleport = TeleportImpl;
7224
7194
 
7195
+ const COMPONENTS = 'components';
7196
+ const DIRECTIVES = 'directives';
7197
+ /**
7198
+ * @private
7199
+ */
7200
+ function resolveComponent(name, maybeSelfReference) {
7201
+ return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
7202
+ }
7203
+ const NULL_DYNAMIC_COMPONENT = Symbol();
7204
+ /**
7205
+ * @private
7206
+ */
7207
+ function resolveDynamicComponent(component) {
7208
+ if (isString(component)) {
7209
+ return resolveAsset(COMPONENTS, component, false) || component;
7210
+ }
7211
+ else {
7212
+ // invalid types will fallthrough to createVNode and raise warning
7213
+ return (component || NULL_DYNAMIC_COMPONENT);
7214
+ }
7215
+ }
7216
+ /**
7217
+ * @private
7218
+ */
7219
+ function resolveDirective(name) {
7220
+ return resolveAsset(DIRECTIVES, name);
7221
+ }
7222
+ // implementation
7223
+ function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
7224
+ const instance = currentRenderingInstance || currentInstance;
7225
+ if (instance) {
7226
+ const Component = instance.type;
7227
+ // explicit self name has highest priority
7228
+ if (type === COMPONENTS) {
7229
+ const selfName = getComponentName(Component);
7230
+ if (selfName &&
7231
+ (selfName === name ||
7232
+ selfName === camelize(name) ||
7233
+ selfName === capitalize(camelize(name)))) {
7234
+ return Component;
7235
+ }
7236
+ }
7237
+ const res =
7238
+ // local registration
7239
+ // check instance[type] first which is resolved for options API
7240
+ resolve(instance[type] || Component[type], name) ||
7241
+ // global registration
7242
+ resolve(instance.appContext[type], name);
7243
+ if (!res && maybeSelfReference) {
7244
+ // fallback to implicit self-reference
7245
+ return Component;
7246
+ }
7247
+ if (warnMissing && !res) {
7248
+ warn(`Failed to resolve ${type.slice(0, -1)}: ${name}`);
7249
+ }
7250
+ return res;
7251
+ }
7252
+ else {
7253
+ warn(`resolve${capitalize(type.slice(0, -1))} ` +
7254
+ `can only be used in render() or setup().`);
7255
+ }
7256
+ }
7257
+ function resolve(registry, name) {
7258
+ return (registry &&
7259
+ (registry[name] ||
7260
+ registry[camelize(name)] ||
7261
+ registry[capitalize(camelize(name))]));
7262
+ }
7263
+
7225
7264
  const Fragment = Symbol('Fragment' );
7226
7265
  const Text = Symbol('Text' );
7227
- const Comment = Symbol('Comment' );
7266
+ const Comment$1 = Symbol('Comment' );
7228
7267
  const Static = Symbol('Static' );
7229
7268
  // Since v-if and v-for are the two possible ways node structure can dynamically
7230
7269
  // change, once we consider v-if branches and each v-for fragment a block, we
@@ -7343,7 +7382,7 @@ var VueRuntimeDOM = (function (exports) {
7343
7382
  if (!type) {
7344
7383
  warn(`Invalid vnode type when creating vnode: ${type}.`);
7345
7384
  }
7346
- type = Comment;
7385
+ type = Comment$1;
7347
7386
  }
7348
7387
  if (isVNode(type)) {
7349
7388
  // createVNode receiving an existing vnode. This happens in cases like
@@ -7431,9 +7470,7 @@ var VueRuntimeDOM = (function (exports) {
7431
7470
  normalizeChildren(vnode, children);
7432
7471
  // normalize suspense children
7433
7472
  if (shapeFlag & 128 /* SUSPENSE */) {
7434
- const { content, fallback } = normalizeSuspenseChildren(vnode);
7435
- vnode.ssContent = content;
7436
- vnode.ssFallback = fallback;
7473
+ type.normalize(vnode);
7437
7474
  }
7438
7475
  if (isBlockTreeEnabled > 0 &&
7439
7476
  // avoid a block node from tracking itself
@@ -7544,22 +7581,24 @@ var VueRuntimeDOM = (function (exports) {
7544
7581
  // block to ensure correct updates.
7545
7582
  asBlock = false) {
7546
7583
  return asBlock
7547
- ? (openBlock(), createBlock(Comment, null, text))
7548
- : createVNode(Comment, null, text);
7584
+ ? (openBlock(), createBlock(Comment$1, null, text))
7585
+ : createVNode(Comment$1, null, text);
7549
7586
  }
7550
7587
  function normalizeVNode(child) {
7551
7588
  if (child == null || typeof child === 'boolean') {
7552
7589
  // empty placeholder
7553
- return createVNode(Comment);
7590
+ return createVNode(Comment$1);
7554
7591
  }
7555
7592
  else if (isArray(child)) {
7556
7593
  // fragment
7557
- return createVNode(Fragment, null, child);
7594
+ return createVNode(Fragment, null,
7595
+ // #3666, avoid reference pollution when reusing vnode
7596
+ child.slice());
7558
7597
  }
7559
7598
  else if (typeof child === 'object') {
7560
7599
  // already vnode, this should be the most common since compiled templates
7561
7600
  // always produce all-vnode children arrays
7562
- return child.el === null ? child : cloneVNode(child);
7601
+ return cloneIfMounted(child);
7563
7602
  }
7564
7603
  else {
7565
7604
  // strings and numbers
@@ -7758,7 +7797,7 @@ var VueRuntimeDOM = (function (exports) {
7758
7797
  return vnodes.some(child => {
7759
7798
  if (!isVNode(child))
7760
7799
  return true;
7761
- if (child.type === Comment)
7800
+ if (child.type === Comment$1)
7762
7801
  return false;
7763
7802
  if (child.type === Fragment &&
7764
7803
  !ensureValidVNode(child.children))
@@ -8072,6 +8111,8 @@ var VueRuntimeDOM = (function (exports) {
8072
8111
  emitted: null,
8073
8112
  // props default value
8074
8113
  propsDefaults: EMPTY_OBJ,
8114
+ // inheritAttrs
8115
+ inheritAttrs: type.inheritAttrs,
8075
8116
  // state
8076
8117
  ctx: EMPTY_OBJ,
8077
8118
  data: EMPTY_OBJ,
@@ -8280,7 +8321,7 @@ var VueRuntimeDOM = (function (exports) {
8280
8321
  {
8281
8322
  currentInstance = instance;
8282
8323
  pauseTracking();
8283
- applyOptions(instance, Component);
8324
+ applyOptions(instance);
8284
8325
  resetTracking();
8285
8326
  currentInstance = null;
8286
8327
  }
@@ -8638,7 +8679,7 @@ var VueRuntimeDOM = (function (exports) {
8638
8679
  }
8639
8680
 
8640
8681
  // Core API ------------------------------------------------------------------
8641
- const version = "3.1.0-beta.5";
8682
+ const version = "3.1.1";
8642
8683
  /**
8643
8684
  * SSR utils for \@vue/server-renderer. Only exposed in cjs builds.
8644
8685
  * @internal
@@ -8869,6 +8910,9 @@ var VueRuntimeDOM = (function (exports) {
8869
8910
  if (el.value !== newValue) {
8870
8911
  el.value = newValue;
8871
8912
  }
8913
+ if (value == null) {
8914
+ el.removeAttribute(key);
8915
+ }
8872
8916
  return;
8873
8917
  }
8874
8918
  if (value === '' || value == null) {
@@ -9156,6 +9200,29 @@ var VueRuntimeDOM = (function (exports) {
9156
9200
  leaveToClass: String
9157
9201
  };
9158
9202
  const TransitionPropsValidators = (Transition.props = /*#__PURE__*/ extend({}, BaseTransition.props, DOMTransitionPropsValidators));
9203
+ /**
9204
+ * #3227 Incoming hooks may be merged into arrays when wrapping Transition
9205
+ * with custom HOCs.
9206
+ */
9207
+ const callHook$1 = (hook, args = []) => {
9208
+ if (isArray(hook)) {
9209
+ hook.forEach(h => h(...args));
9210
+ }
9211
+ else if (hook) {
9212
+ hook(...args);
9213
+ }
9214
+ };
9215
+ /**
9216
+ * Check if a hook expects a callback (2nd arg), which means the user
9217
+ * intends to explicitly control the end of the transition.
9218
+ */
9219
+ const hasExplicitCallback = (hook) => {
9220
+ return hook
9221
+ ? isArray(hook)
9222
+ ? hook.some(h => h.length > 1)
9223
+ : hook.length > 1
9224
+ : false;
9225
+ };
9159
9226
  function resolveTransitionProps(rawProps) {
9160
9227
  const baseProps = {};
9161
9228
  for (const key in rawProps) {
@@ -9185,11 +9252,11 @@ var VueRuntimeDOM = (function (exports) {
9185
9252
  return (el, done) => {
9186
9253
  const hook = isAppear ? onAppear : onEnter;
9187
9254
  const resolve = () => finishEnter(el, isAppear, done);
9188
- hook && hook(el, resolve);
9255
+ callHook$1(hook, [el, resolve]);
9189
9256
  nextFrame(() => {
9190
9257
  removeTransitionClass(el, isAppear ? appearFromClass : enterFromClass);
9191
9258
  addTransitionClass(el, isAppear ? appearToClass : enterToClass);
9192
- if (!(hook && hook.length > 1)) {
9259
+ if (!hasExplicitCallback(hook)) {
9193
9260
  whenTransitionEnds(el, type, enterDuration, resolve);
9194
9261
  }
9195
9262
  });
@@ -9197,12 +9264,12 @@ var VueRuntimeDOM = (function (exports) {
9197
9264
  };
9198
9265
  return extend(baseProps, {
9199
9266
  onBeforeEnter(el) {
9200
- onBeforeEnter && onBeforeEnter(el);
9267
+ callHook$1(onBeforeEnter, [el]);
9201
9268
  addTransitionClass(el, enterFromClass);
9202
9269
  addTransitionClass(el, enterActiveClass);
9203
9270
  },
9204
9271
  onBeforeAppear(el) {
9205
- onBeforeAppear && onBeforeAppear(el);
9272
+ callHook$1(onBeforeAppear, [el]);
9206
9273
  addTransitionClass(el, appearFromClass);
9207
9274
  addTransitionClass(el, appearActiveClass);
9208
9275
  },
@@ -9217,23 +9284,23 @@ var VueRuntimeDOM = (function (exports) {
9217
9284
  nextFrame(() => {
9218
9285
  removeTransitionClass(el, leaveFromClass);
9219
9286
  addTransitionClass(el, leaveToClass);
9220
- if (!(onLeave && onLeave.length > 1)) {
9287
+ if (!hasExplicitCallback(onLeave)) {
9221
9288
  whenTransitionEnds(el, type, leaveDuration, resolve);
9222
9289
  }
9223
9290
  });
9224
- onLeave && onLeave(el, resolve);
9291
+ callHook$1(onLeave, [el, resolve]);
9225
9292
  },
9226
9293
  onEnterCancelled(el) {
9227
9294
  finishEnter(el, false);
9228
- onEnterCancelled && onEnterCancelled(el);
9295
+ callHook$1(onEnterCancelled, [el]);
9229
9296
  },
9230
9297
  onAppearCancelled(el) {
9231
9298
  finishEnter(el, true);
9232
- onAppearCancelled && onAppearCancelled(el);
9299
+ callHook$1(onAppearCancelled, [el]);
9233
9300
  },
9234
9301
  onLeaveCancelled(el) {
9235
9302
  finishLeave(el);
9236
- onLeaveCancelled && onLeaveCancelled(el);
9303
+ callHook$1(onLeaveCancelled, [el]);
9237
9304
  }
9238
9305
  });
9239
9306
  }
@@ -9698,12 +9765,13 @@ var VueRuntimeDOM = (function (exports) {
9698
9765
  }
9699
9766
  else {
9700
9767
  if (looseEqual(getValue(option), value)) {
9701
- el.selectedIndex = i;
9768
+ if (el.selectedIndex !== i)
9769
+ el.selectedIndex = i;
9702
9770
  return;
9703
9771
  }
9704
9772
  }
9705
9773
  }
9706
- if (!isMultiple) {
9774
+ if (!isMultiple && el.selectedIndex !== -1) {
9707
9775
  el.selectedIndex = -1;
9708
9776
  }
9709
9777
  }
@@ -9973,7 +10041,7 @@ var VueRuntimeDOM = (function (exports) {
9973
10041
  }
9974
10042
 
9975
10043
  exports.BaseTransition = BaseTransition;
9976
- exports.Comment = Comment;
10044
+ exports.Comment = Comment$1;
9977
10045
  exports.Fragment = Fragment;
9978
10046
  exports.KeepAlive = KeepAlive;
9979
10047
  exports.Static = Static;