@vue/compat 3.6.0-alpha.3 → 3.6.0-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compat v3.6.0-alpha.3
2
+ * @vue/compat v3.6.0-alpha.4
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -87,6 +87,9 @@ const toHandlerKey = cacheStringFunction(
87
87
  return s;
88
88
  }
89
89
  );
90
+ const getModifierPropName = (name) => {
91
+ return `${name === "modelValue" || name === "model-value" ? "model" : name}Modifiers${name === "model" ? "$" : ""}`;
92
+ };
90
93
  const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
91
94
  const invokeArrayFns = (fns, ...arg) => {
92
95
  for (let i = 0; i < fns.length; i++) {
@@ -6154,7 +6157,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
6154
6157
  return vm;
6155
6158
  }
6156
6159
  }
6157
- Vue.version = `2.6.14-compat:${"3.6.0-alpha.3"}`;
6160
+ Vue.version = `2.6.14-compat:${"3.6.0-alpha.4"}`;
6158
6161
  Vue.config = singletonApp.config;
6159
6162
  Vue.use = (plugin, ...options) => {
6160
6163
  if (plugin && isFunction(plugin.install)) {
@@ -8865,7 +8868,7 @@ function useModel(props, name, options = EMPTY_OBJ) {
8865
8868
  return res;
8866
8869
  }
8867
8870
  const getModelModifiers = (props, modelName, getter) => {
8868
- return modelName === "modelValue" || modelName === "model-value" ? getter(props, "modelModifiers") : getter(props, `${modelName}Modifiers`) || getter(props, `${camelize(modelName)}Modifiers`) || getter(props, `${hyphenate(modelName)}Modifiers`);
8871
+ return getter(props, getModifierPropName(modelName)) || getter(props, `${camelize(modelName)}Modifiers`) || getter(props, `${hyphenate(modelName)}Modifiers`);
8869
8872
  };
8870
8873
 
8871
8874
  function emit(instance, event, ...rawArgs) {
@@ -10227,6 +10230,17 @@ const setCurrentInstance = (instance, scope = instance !== null ? instance.scope
10227
10230
  simpleSetCurrentInstance(instance);
10228
10231
  }
10229
10232
  };
10233
+ const internalOptions = ["ce", "type"];
10234
+ const useInstanceOption = (key, silent = false) => {
10235
+ const instance = getCurrentGenericInstance();
10236
+ if (!instance) {
10237
+ return { hasInstance: false, value: void 0 };
10238
+ }
10239
+ if (!internalOptions.includes(key)) {
10240
+ return { hasInstance: true, value: void 0 };
10241
+ }
10242
+ return { hasInstance: true, value: instance[key] };
10243
+ };
10230
10244
 
10231
10245
  const emptyAppContext = createAppContext();
10232
10246
  let uid = 0;
@@ -10558,7 +10572,7 @@ function isMemoSame(cached, memo) {
10558
10572
  return true;
10559
10573
  }
10560
10574
 
10561
- const version = "3.6.0-alpha.3";
10575
+ const version = "3.6.0-alpha.4";
10562
10576
  const warn$1 = NOOP;
10563
10577
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
10564
10578
  const devtools = void 0;
@@ -11388,12 +11402,9 @@ const defineSSRCustomElement = (/* @__NO_SIDE_EFFECTS__ */ (options, extraOption
11388
11402
  });
11389
11403
  const BaseClass = typeof HTMLElement !== "undefined" ? HTMLElement : class {
11390
11404
  };
11391
- class VueElement extends BaseClass {
11392
- constructor(_def, _props = {}, _createApp = createApp) {
11405
+ class VueElementBase extends BaseClass {
11406
+ constructor(def, props = {}, createAppFn) {
11393
11407
  super();
11394
- this._def = _def;
11395
- this._props = _props;
11396
- this._createApp = _createApp;
11397
11408
  this._isVueCE = true;
11398
11409
  /**
11399
11410
  * @internal
@@ -11403,23 +11414,23 @@ class VueElement extends BaseClass {
11403
11414
  * @internal
11404
11415
  */
11405
11416
  this._app = null;
11406
- /**
11407
- * @internal
11408
- */
11409
- this._nonce = this._def.nonce;
11410
11417
  this._connected = false;
11411
11418
  this._resolved = false;
11412
- this._patching = false;
11413
- this._dirty = false;
11414
11419
  this._numberProps = null;
11415
11420
  this._styleChildren = /* @__PURE__ */ new WeakSet();
11421
+ this._patching = false;
11422
+ this._dirty = false;
11416
11423
  this._ob = null;
11417
- if (this.shadowRoot && _createApp !== createApp) {
11424
+ this._def = def;
11425
+ this._props = props;
11426
+ this._createApp = createAppFn;
11427
+ this._nonce = def.nonce;
11428
+ if (this._needsHydration()) {
11418
11429
  this._root = this.shadowRoot;
11419
11430
  } else {
11420
- if (_def.shadowRoot !== false) {
11431
+ if (def.shadowRoot !== false) {
11421
11432
  this.attachShadow(
11422
- extend({}, _def.shadowRootOptions, {
11433
+ extend({}, def.shadowRootOptions, {
11423
11434
  mode: "open"
11424
11435
  })
11425
11436
  );
@@ -11437,14 +11448,14 @@ class VueElement extends BaseClass {
11437
11448
  this._connected = true;
11438
11449
  let parent = this;
11439
11450
  while (parent = parent && (parent.parentNode || parent.host)) {
11440
- if (parent instanceof VueElement) {
11451
+ if (parent instanceof VueElementBase) {
11441
11452
  this._parent = parent;
11442
11453
  break;
11443
11454
  }
11444
11455
  }
11445
11456
  if (!this._instance) {
11446
11457
  if (this._resolved) {
11447
- this._mount(this._def);
11458
+ this._mountComponent(this._def);
11448
11459
  } else {
11449
11460
  if (parent && parent._pendingResolve) {
11450
11461
  this._pendingResolve = parent._pendingResolve.then(() => {
@@ -11457,20 +11468,6 @@ class VueElement extends BaseClass {
11457
11468
  }
11458
11469
  }
11459
11470
  }
11460
- _setParent(parent = this._parent) {
11461
- if (parent) {
11462
- this._instance.parent = parent._instance;
11463
- this._inheritParentContext(parent);
11464
- }
11465
- }
11466
- _inheritParentContext(parent = this._parent) {
11467
- if (parent && this._app) {
11468
- Object.setPrototypeOf(
11469
- this._app._context.provides,
11470
- parent._instance.provides
11471
- );
11472
- }
11473
- }
11474
11471
  disconnectedCallback() {
11475
11472
  this._connected = false;
11476
11473
  nextTick(() => {
@@ -11479,9 +11476,7 @@ class VueElement extends BaseClass {
11479
11476
  this._ob.disconnect();
11480
11477
  this._ob = null;
11481
11478
  }
11482
- this._app && this._app.unmount();
11483
- if (this._instance) this._instance.ce = void 0;
11484
- this._app = this._instance = null;
11479
+ this._unmount();
11485
11480
  if (this._teleportTargets) {
11486
11481
  this._teleportTargets.clear();
11487
11482
  this._teleportTargets = void 0;
@@ -11489,6 +11484,20 @@ class VueElement extends BaseClass {
11489
11484
  }
11490
11485
  });
11491
11486
  }
11487
+ _setParent(parent = this._parent) {
11488
+ if (parent && this._instance) {
11489
+ this._instance.parent = parent._instance;
11490
+ this._inheritParentContext(parent);
11491
+ }
11492
+ }
11493
+ _inheritParentContext(parent = this._parent) {
11494
+ if (parent && this._app) {
11495
+ Object.setPrototypeOf(
11496
+ this._app._context.provides,
11497
+ parent._instance.provides
11498
+ );
11499
+ }
11500
+ }
11492
11501
  _processMutations(mutations) {
11493
11502
  for (const m of mutations) {
11494
11503
  this._setAttr(m.attributeName);
@@ -11506,7 +11515,7 @@ class VueElement extends BaseClass {
11506
11515
  }
11507
11516
  this._ob = new MutationObserver(this._processMutations.bind(this));
11508
11517
  this._ob.observe(this, { attributes: true });
11509
- const resolve = (def, isAsync = false) => {
11518
+ const resolve = (def) => {
11510
11519
  this._resolved = true;
11511
11520
  this._pendingResolve = void 0;
11512
11521
  const { props, styles } = def;
@@ -11527,26 +11536,25 @@ class VueElement extends BaseClass {
11527
11536
  if (this.shadowRoot) {
11528
11537
  this._applyStyles(styles);
11529
11538
  }
11530
- this._mount(def);
11539
+ this._mountComponent(def);
11531
11540
  };
11532
11541
  const asyncDef = this._def.__asyncLoader;
11533
11542
  if (asyncDef) {
11543
+ const { configureApp } = this._def;
11534
11544
  this._pendingResolve = asyncDef().then((def) => {
11535
- def.configureApp = this._def.configureApp;
11536
- resolve(this._def = def, true);
11545
+ def.configureApp = configureApp;
11546
+ this._def = def;
11547
+ resolve(def);
11537
11548
  });
11538
11549
  } else {
11539
11550
  resolve(this._def);
11540
11551
  }
11541
11552
  }
11542
- _mount(def) {
11543
- this._app = this._createApp(def);
11544
- this._inheritParentContext();
11545
- if (def.configureApp) {
11546
- def.configureApp(this._app);
11547
- }
11548
- this._app._ceVNode = this._createVNode();
11549
- this._app.mount(this._root);
11553
+ _mountComponent(def) {
11554
+ this._mount(def);
11555
+ this._processExposed();
11556
+ }
11557
+ _processExposed() {
11550
11558
  const exposed = this._instance && this._instance.exposed;
11551
11559
  if (!exposed) return;
11552
11560
  for (const key in exposed) {
@@ -11558,6 +11566,25 @@ class VueElement extends BaseClass {
11558
11566
  }
11559
11567
  }
11560
11568
  }
11569
+ _processInstance() {
11570
+ this._instance.ce = this;
11571
+ this._instance.isCE = true;
11572
+ const dispatch = (event, args) => {
11573
+ this.dispatchEvent(
11574
+ new CustomEvent(
11575
+ event,
11576
+ isPlainObject(args[0]) ? extend({ detail: args }, args[0]) : { detail: args }
11577
+ )
11578
+ );
11579
+ };
11580
+ this._instance.emit = (event, ...args) => {
11581
+ dispatch(event, args);
11582
+ if (hyphenate(event) !== event) {
11583
+ dispatch(hyphenate(event), args);
11584
+ }
11585
+ };
11586
+ this._setParent();
11587
+ }
11561
11588
  _resolveProps(def) {
11562
11589
  const { props } = def;
11563
11590
  const declaredPropKeys = isArray(props) ? props : Object.keys(props || {});
@@ -11603,7 +11630,7 @@ class VueElement extends BaseClass {
11603
11630
  delete this._props[key];
11604
11631
  } else {
11605
11632
  this._props[key] = val;
11606
- if (key === "key" && this._app) {
11633
+ if (key === "key" && this._app && this._app._ceVNode) {
11607
11634
  this._app._ceVNode.key = val;
11608
11635
  }
11609
11636
  }
@@ -11627,41 +11654,6 @@ class VueElement extends BaseClass {
11627
11654
  }
11628
11655
  }
11629
11656
  }
11630
- _update() {
11631
- const vnode = this._createVNode();
11632
- if (this._app) vnode.appContext = this._app._context;
11633
- render(vnode, this._root);
11634
- }
11635
- _createVNode() {
11636
- const baseProps = {};
11637
- if (!this.shadowRoot) {
11638
- baseProps.onVnodeMounted = baseProps.onVnodeUpdated = this._renderSlots.bind(this);
11639
- }
11640
- const vnode = createVNode(this._def, extend(baseProps, this._props));
11641
- if (!this._instance) {
11642
- vnode.ce = (instance) => {
11643
- this._instance = instance;
11644
- instance.ce = this;
11645
- instance.isCE = true;
11646
- const dispatch = (event, args) => {
11647
- this.dispatchEvent(
11648
- new CustomEvent(
11649
- event,
11650
- isPlainObject(args[0]) ? extend({ detail: args }, args[0]) : { detail: args }
11651
- )
11652
- );
11653
- };
11654
- instance.emit = (event, ...args) => {
11655
- dispatch(event, args);
11656
- if (hyphenate(event) !== event) {
11657
- dispatch(hyphenate(event), args);
11658
- }
11659
- };
11660
- this._setParent();
11661
- };
11662
- }
11663
- return vnode;
11664
- }
11665
11657
  _applyStyles(styles, owner) {
11666
11658
  if (!styles) return;
11667
11659
  if (owner) {
@@ -11696,11 +11688,13 @@ class VueElement extends BaseClass {
11696
11688
  _renderSlots() {
11697
11689
  const outlets = this._getSlots();
11698
11690
  const scopeId = this._instance.type.__scopeId;
11691
+ const slotReplacements = /* @__PURE__ */ new Map();
11699
11692
  for (let i = 0; i < outlets.length; i++) {
11700
11693
  const o = outlets[i];
11701
11694
  const slotName = o.getAttribute("name") || "default";
11702
11695
  const content = this._slots[slotName];
11703
11696
  const parent = o.parentNode;
11697
+ const replacementNodes = [];
11704
11698
  if (content) {
11705
11699
  for (const n of content) {
11706
11700
  if (scopeId && n.nodeType === 1) {
@@ -11713,12 +11707,19 @@ class VueElement extends BaseClass {
11713
11707
  }
11714
11708
  }
11715
11709
  parent.insertBefore(n, o);
11710
+ replacementNodes.push(n);
11716
11711
  }
11717
11712
  } else {
11718
- while (o.firstChild) parent.insertBefore(o.firstChild, o);
11713
+ while (o.firstChild) {
11714
+ const child = o.firstChild;
11715
+ parent.insertBefore(child, o);
11716
+ replacementNodes.push(child);
11717
+ }
11719
11718
  }
11720
11719
  parent.removeChild(o);
11720
+ slotReplacements.set(o, replacementNodes);
11721
11721
  }
11722
+ this._updateSlotNodes(slotReplacements);
11722
11723
  }
11723
11724
  /**
11724
11725
  * @internal
@@ -11765,9 +11766,63 @@ class VueElement extends BaseClass {
11765
11766
  _removeChildStyle(comp) {
11766
11767
  }
11767
11768
  }
11769
+ class VueElement extends VueElementBase {
11770
+ constructor(def, props = {}, createAppFn = createApp) {
11771
+ super(def, props, createAppFn);
11772
+ }
11773
+ _needsHydration() {
11774
+ if (this.shadowRoot && this._createApp !== createApp) {
11775
+ return true;
11776
+ }
11777
+ return false;
11778
+ }
11779
+ _mount(def) {
11780
+ this._app = this._createApp(def);
11781
+ this._inheritParentContext();
11782
+ if (def.configureApp) {
11783
+ def.configureApp(this._app);
11784
+ }
11785
+ this._app._ceVNode = this._createVNode();
11786
+ this._app.mount(this._root);
11787
+ }
11788
+ _update() {
11789
+ if (!this._app) return;
11790
+ const vnode = this._createVNode();
11791
+ vnode.appContext = this._app._context;
11792
+ render(vnode, this._root);
11793
+ }
11794
+ _unmount() {
11795
+ if (this._app) {
11796
+ this._app.unmount();
11797
+ }
11798
+ if (this._instance && this._instance.ce) {
11799
+ this._instance.ce = void 0;
11800
+ }
11801
+ this._app = this._instance = null;
11802
+ }
11803
+ /**
11804
+ * Only called when shadowRoot is false
11805
+ */
11806
+ _updateSlotNodes(replacements) {
11807
+ }
11808
+ _createVNode() {
11809
+ const baseProps = {};
11810
+ if (!this.shadowRoot) {
11811
+ baseProps.onVnodeMounted = baseProps.onVnodeUpdated = this._renderSlots.bind(this);
11812
+ }
11813
+ const vnode = createVNode(this._def, extend(baseProps, this._props));
11814
+ if (!this._instance) {
11815
+ vnode.ce = (instance) => {
11816
+ this._instance = instance;
11817
+ this._processInstance();
11818
+ };
11819
+ }
11820
+ return vnode;
11821
+ }
11822
+ }
11768
11823
  function useHost(caller) {
11769
- const instance = getCurrentInstance();
11770
- const el = instance && instance.ce;
11824
+ const { hasInstance, value } = useInstanceOption("ce", true);
11825
+ const el = value;
11771
11826
  if (el) {
11772
11827
  return el;
11773
11828
  }
@@ -11780,11 +11835,11 @@ function useShadowRoot() {
11780
11835
 
11781
11836
  function useCssModule(name = "$style") {
11782
11837
  {
11783
- const instance = getCurrentInstance();
11784
- if (!instance) {
11838
+ const { hasInstance, value: type } = useInstanceOption("type", true);
11839
+ if (!hasInstance) {
11785
11840
  return EMPTY_OBJ;
11786
11841
  }
11787
- const modules = instance.type.__cssModules;
11842
+ const modules = type.__cssModules;
11788
11843
  if (!modules) {
11789
11844
  return EMPTY_OBJ;
11790
11845
  }
@@ -12441,6 +12496,7 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
12441
12496
  TransitionGroup: TransitionGroup,
12442
12497
  TriggerOpTypes: TriggerOpTypes,
12443
12498
  VueElement: VueElement,
12499
+ VueElementBase: VueElementBase,
12444
12500
  assertNumber: assertNumber,
12445
12501
  callWithAsyncErrorHandling: callWithAsyncErrorHandling,
12446
12502
  callWithErrorHandling: callWithErrorHandling,
@@ -12505,6 +12561,7 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
12505
12561
  mergeModels: mergeModels,
12506
12562
  mergeProps: mergeProps,
12507
12563
  nextTick: nextTick,
12564
+ nodeOps: nodeOps,
12508
12565
  normalizeClass: normalizeClass,
12509
12566
  normalizeProps: normalizeProps,
12510
12567
  normalizeStyle: normalizeStyle,
@@ -12523,6 +12580,7 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
12523
12580
  onUpdated: onUpdated,
12524
12581
  onWatcherCleanup: onWatcherCleanup,
12525
12582
  openBlock: openBlock,
12583
+ patchProp: patchProp,
12526
12584
  popScopeId: popScopeId,
12527
12585
  provide: provide,
12528
12586
  proxyRefs: proxyRefs,
@@ -12564,6 +12622,7 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
12564
12622
  useCssVars: useCssVars,
12565
12623
  useHost: useHost,
12566
12624
  useId: useId,
12625
+ useInstanceOption: useInstanceOption,
12567
12626
  useModel: useModel,
12568
12627
  useSSRContext: useSSRContext,
12569
12628
  useShadowRoot: useShadowRoot,
@@ -16753,17 +16812,14 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
16753
16812
  knownIds
16754
16813
  );
16755
16814
  const children = [];
16756
- const isTSNode = TS_NODE_TYPES.includes(ast.type);
16757
16815
  ids.sort((a, b) => a.start - b.start);
16758
16816
  ids.forEach((id, i) => {
16759
16817
  const start = id.start - 1;
16760
16818
  const end = id.end - 1;
16761
16819
  const last = ids[i - 1];
16762
- if (!(isTSNode && i === 0)) {
16763
- const leadingText = rawExp.slice(last ? last.end - 1 : 0, start);
16764
- if (leadingText.length || id.prefix) {
16765
- children.push(leadingText + (id.prefix || ``));
16766
- }
16820
+ const leadingText = rawExp.slice(last ? last.end - 1 : 0, start);
16821
+ if (leadingText.length || id.prefix) {
16822
+ children.push(leadingText + (id.prefix || ``));
16767
16823
  }
16768
16824
  const source = rawExp.slice(start, end);
16769
16825
  children.push(
@@ -16778,7 +16834,7 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
16778
16834
  id.isConstant ? 3 : 0
16779
16835
  )
16780
16836
  );
16781
- if (i === ids.length - 1 && end < rawExp.length && !isTSNode) {
16837
+ if (i === ids.length - 1 && end < rawExp.length) {
16782
16838
  children.push(rawExp.slice(end));
16783
16839
  }
16784
16840
  });
@@ -18539,7 +18595,7 @@ const transformModel$1 = (dir, node, context) => {
18539
18595
  }
18540
18596
  if (dir.modifiers.length && node.tagType === 1) {
18541
18597
  const modifiers = dir.modifiers.map((m) => m.content).map((m) => (isSimpleIdentifier(m) ? m : JSON.stringify(m)) + `: true`).join(`, `);
18542
- const modifiersKey = arg ? isStaticExp(arg) ? `${arg.content}Modifiers` : createCompoundExpression([arg, ' + "Modifiers"']) : `modelModifiers`;
18598
+ const modifiersKey = arg ? isStaticExp(arg) ? getModifierPropName(arg.content) : createCompoundExpression([arg, ' + "Modifiers"']) : `modelModifiers`;
18543
18599
  props.push(
18544
18600
  createObjectProperty(
18545
18601
  modifiersKey,
@@ -18876,7 +18932,7 @@ const parserOptions = {
18876
18932
  let ns = parent ? parent.ns : rootNamespace;
18877
18933
  if (parent && ns === 2) {
18878
18934
  if (parent.tag === "annotation-xml") {
18879
- if (tag === "svg") {
18935
+ if (isSVGTag(tag)) {
18880
18936
  return 1;
18881
18937
  }
18882
18938
  if (parent.props.some(
@@ -18893,10 +18949,10 @@ const parserOptions = {
18893
18949
  }
18894
18950
  }
18895
18951
  if (ns === 0) {
18896
- if (tag === "svg") {
18952
+ if (isSVGTag(tag)) {
18897
18953
  return 1;
18898
18954
  }
18899
- if (tag === "math") {
18955
+ if (isMathMLTag(tag)) {
18900
18956
  return 2;
18901
18957
  }
18902
18958
  }