@vue/runtime-dom 3.6.0-alpha.3 → 3.6.0-alpha.5
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.
- package/dist/runtime-dom.cjs.js +155 -108
- package/dist/runtime-dom.cjs.prod.js +132 -88
- package/dist/runtime-dom.d.ts +71 -32
- package/dist/runtime-dom.esm-browser.js +2917 -2790
- package/dist/runtime-dom.esm-browser.prod.js +3 -3
- package/dist/runtime-dom.esm-bundler.js +191 -135
- package/dist/runtime-dom.global.js +2893 -2762
- package/dist/runtime-dom.global.prod.js +3 -3
- package/package.json +4 -4
package/dist/runtime-dom.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/runtime-dom v3.6.0-alpha.
|
|
2
|
+
* @vue/runtime-dom v3.6.0-alpha.5
|
|
3
3
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
@@ -763,12 +763,9 @@ const defineSSRCustomElement = (/* @__NO_SIDE_EFFECTS__ */ (options, extraOption
|
|
|
763
763
|
});
|
|
764
764
|
const BaseClass = typeof HTMLElement !== "undefined" ? HTMLElement : class {
|
|
765
765
|
};
|
|
766
|
-
class
|
|
767
|
-
constructor(
|
|
766
|
+
class VueElementBase extends BaseClass {
|
|
767
|
+
constructor(def, props = {}, createAppFn) {
|
|
768
768
|
super();
|
|
769
|
-
this._def = _def;
|
|
770
|
-
this._props = _props;
|
|
771
|
-
this._createApp = _createApp;
|
|
772
769
|
this._isVueCE = true;
|
|
773
770
|
/**
|
|
774
771
|
* @internal
|
|
@@ -778,28 +775,23 @@ class VueElement extends BaseClass {
|
|
|
778
775
|
* @internal
|
|
779
776
|
*/
|
|
780
777
|
this._app = null;
|
|
781
|
-
/**
|
|
782
|
-
* @internal
|
|
783
|
-
*/
|
|
784
|
-
this._nonce = this._def.nonce;
|
|
785
778
|
this._connected = false;
|
|
786
779
|
this._resolved = false;
|
|
787
|
-
this._patching = false;
|
|
788
|
-
this._dirty = false;
|
|
789
780
|
this._numberProps = null;
|
|
790
781
|
this._styleChildren = /* @__PURE__ */ new WeakSet();
|
|
782
|
+
this._patching = false;
|
|
783
|
+
this._dirty = false;
|
|
791
784
|
this._ob = null;
|
|
792
|
-
|
|
785
|
+
this._def = def;
|
|
786
|
+
this._props = props;
|
|
787
|
+
this._createApp = createAppFn;
|
|
788
|
+
this._nonce = def.nonce;
|
|
789
|
+
if (this._needsHydration()) {
|
|
793
790
|
this._root = this.shadowRoot;
|
|
794
791
|
} else {
|
|
795
|
-
if (
|
|
796
|
-
runtimeCore.warn(
|
|
797
|
-
`Custom element has pre-rendered declarative shadow root but is not defined as hydratable. Use \`defineSSRCustomElement\`.`
|
|
798
|
-
);
|
|
799
|
-
}
|
|
800
|
-
if (_def.shadowRoot !== false) {
|
|
792
|
+
if (def.shadowRoot !== false) {
|
|
801
793
|
this.attachShadow(
|
|
802
|
-
shared.extend({},
|
|
794
|
+
shared.extend({}, def.shadowRootOptions, {
|
|
803
795
|
mode: "open"
|
|
804
796
|
})
|
|
805
797
|
);
|
|
@@ -817,14 +809,14 @@ class VueElement extends BaseClass {
|
|
|
817
809
|
this._connected = true;
|
|
818
810
|
let parent = this;
|
|
819
811
|
while (parent = parent && (parent.parentNode || parent.host)) {
|
|
820
|
-
if (parent instanceof
|
|
812
|
+
if (parent instanceof VueElementBase) {
|
|
821
813
|
this._parent = parent;
|
|
822
814
|
break;
|
|
823
815
|
}
|
|
824
816
|
}
|
|
825
817
|
if (!this._instance) {
|
|
826
818
|
if (this._resolved) {
|
|
827
|
-
this.
|
|
819
|
+
this._mountComponent(this._def);
|
|
828
820
|
} else {
|
|
829
821
|
if (parent && parent._pendingResolve) {
|
|
830
822
|
this._pendingResolve = parent._pendingResolve.then(() => {
|
|
@@ -837,20 +829,6 @@ class VueElement extends BaseClass {
|
|
|
837
829
|
}
|
|
838
830
|
}
|
|
839
831
|
}
|
|
840
|
-
_setParent(parent = this._parent) {
|
|
841
|
-
if (parent) {
|
|
842
|
-
this._instance.parent = parent._instance;
|
|
843
|
-
this._inheritParentContext(parent);
|
|
844
|
-
}
|
|
845
|
-
}
|
|
846
|
-
_inheritParentContext(parent = this._parent) {
|
|
847
|
-
if (parent && this._app) {
|
|
848
|
-
Object.setPrototypeOf(
|
|
849
|
-
this._app._context.provides,
|
|
850
|
-
parent._instance.provides
|
|
851
|
-
);
|
|
852
|
-
}
|
|
853
|
-
}
|
|
854
832
|
disconnectedCallback() {
|
|
855
833
|
this._connected = false;
|
|
856
834
|
runtimeCore.nextTick(() => {
|
|
@@ -859,9 +837,7 @@ class VueElement extends BaseClass {
|
|
|
859
837
|
this._ob.disconnect();
|
|
860
838
|
this._ob = null;
|
|
861
839
|
}
|
|
862
|
-
this.
|
|
863
|
-
if (this._instance) this._instance.ce = void 0;
|
|
864
|
-
this._app = this._instance = null;
|
|
840
|
+
this._unmount();
|
|
865
841
|
if (this._teleportTargets) {
|
|
866
842
|
this._teleportTargets.clear();
|
|
867
843
|
this._teleportTargets = void 0;
|
|
@@ -869,6 +845,20 @@ class VueElement extends BaseClass {
|
|
|
869
845
|
}
|
|
870
846
|
});
|
|
871
847
|
}
|
|
848
|
+
_setParent(parent = this._parent) {
|
|
849
|
+
if (parent && this._instance) {
|
|
850
|
+
this._instance.parent = parent._instance;
|
|
851
|
+
this._inheritParentContext(parent);
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
_inheritParentContext(parent = this._parent) {
|
|
855
|
+
if (parent && this._app) {
|
|
856
|
+
Object.setPrototypeOf(
|
|
857
|
+
this._app._context.provides,
|
|
858
|
+
parent._instance.provides
|
|
859
|
+
);
|
|
860
|
+
}
|
|
861
|
+
}
|
|
872
862
|
_processMutations(mutations) {
|
|
873
863
|
for (const m of mutations) {
|
|
874
864
|
this._setAttr(m.attributeName);
|
|
@@ -886,7 +876,7 @@ class VueElement extends BaseClass {
|
|
|
886
876
|
}
|
|
887
877
|
this._ob = new MutationObserver(this._processMutations.bind(this));
|
|
888
878
|
this._ob.observe(this, { attributes: true });
|
|
889
|
-
const resolve = (def
|
|
879
|
+
const resolve = (def) => {
|
|
890
880
|
this._resolved = true;
|
|
891
881
|
this._pendingResolve = void 0;
|
|
892
882
|
const { props, styles } = def;
|
|
@@ -911,29 +901,25 @@ class VueElement extends BaseClass {
|
|
|
911
901
|
"Custom element style injection is not supported when using shadowRoot: false"
|
|
912
902
|
);
|
|
913
903
|
}
|
|
914
|
-
this.
|
|
904
|
+
this._mountComponent(def);
|
|
915
905
|
};
|
|
916
906
|
const asyncDef = this._def.__asyncLoader;
|
|
917
907
|
if (asyncDef) {
|
|
908
|
+
const { configureApp } = this._def;
|
|
918
909
|
this._pendingResolve = asyncDef().then((def) => {
|
|
919
|
-
def.configureApp =
|
|
920
|
-
|
|
910
|
+
def.configureApp = configureApp;
|
|
911
|
+
this._def = def;
|
|
912
|
+
resolve(def);
|
|
921
913
|
});
|
|
922
914
|
} else {
|
|
923
915
|
resolve(this._def);
|
|
924
916
|
}
|
|
925
917
|
}
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
this._inheritParentContext();
|
|
932
|
-
if (def.configureApp) {
|
|
933
|
-
def.configureApp(this._app);
|
|
934
|
-
}
|
|
935
|
-
this._app._ceVNode = this._createVNode();
|
|
936
|
-
this._app.mount(this._root);
|
|
918
|
+
_mountComponent(def) {
|
|
919
|
+
this._mount(def);
|
|
920
|
+
this._processExposed();
|
|
921
|
+
}
|
|
922
|
+
_processExposed() {
|
|
937
923
|
const exposed = this._instance && this._instance.exposed;
|
|
938
924
|
if (!exposed) return;
|
|
939
925
|
for (const key in exposed) {
|
|
@@ -947,6 +933,38 @@ class VueElement extends BaseClass {
|
|
|
947
933
|
}
|
|
948
934
|
}
|
|
949
935
|
}
|
|
936
|
+
_processInstance() {
|
|
937
|
+
this._instance.ce = this;
|
|
938
|
+
this._instance.isCE = true;
|
|
939
|
+
{
|
|
940
|
+
this._instance.ceReload = (newStyles) => {
|
|
941
|
+
if (this._styles) {
|
|
942
|
+
this._styles.forEach((s) => this._root.removeChild(s));
|
|
943
|
+
this._styles.length = 0;
|
|
944
|
+
}
|
|
945
|
+
this._applyStyles(newStyles);
|
|
946
|
+
if (!this._instance.vapor) {
|
|
947
|
+
this._instance = null;
|
|
948
|
+
}
|
|
949
|
+
this._update();
|
|
950
|
+
};
|
|
951
|
+
}
|
|
952
|
+
const dispatch = (event, args) => {
|
|
953
|
+
this.dispatchEvent(
|
|
954
|
+
new CustomEvent(
|
|
955
|
+
event,
|
|
956
|
+
shared.isPlainObject(args[0]) ? shared.extend({ detail: args }, args[0]) : { detail: args }
|
|
957
|
+
)
|
|
958
|
+
);
|
|
959
|
+
};
|
|
960
|
+
this._instance.emit = (event, ...args) => {
|
|
961
|
+
dispatch(event, args);
|
|
962
|
+
if (shared.hyphenate(event) !== event) {
|
|
963
|
+
dispatch(shared.hyphenate(event), args);
|
|
964
|
+
}
|
|
965
|
+
};
|
|
966
|
+
this._setParent();
|
|
967
|
+
}
|
|
950
968
|
_resolveProps(def) {
|
|
951
969
|
const { props } = def;
|
|
952
970
|
const declaredPropKeys = shared.isArray(props) ? props : Object.keys(props || {});
|
|
@@ -992,7 +1010,7 @@ class VueElement extends BaseClass {
|
|
|
992
1010
|
delete this._props[key];
|
|
993
1011
|
} else {
|
|
994
1012
|
this._props[key] = val;
|
|
995
|
-
if (key === "key" && this._app) {
|
|
1013
|
+
if (key === "key" && this._app && this._app._ceVNode) {
|
|
996
1014
|
this._app._ceVNode.key = val;
|
|
997
1015
|
}
|
|
998
1016
|
}
|
|
@@ -1016,52 +1034,6 @@ class VueElement extends BaseClass {
|
|
|
1016
1034
|
}
|
|
1017
1035
|
}
|
|
1018
1036
|
}
|
|
1019
|
-
_update() {
|
|
1020
|
-
const vnode = this._createVNode();
|
|
1021
|
-
if (this._app) vnode.appContext = this._app._context;
|
|
1022
|
-
render(vnode, this._root);
|
|
1023
|
-
}
|
|
1024
|
-
_createVNode() {
|
|
1025
|
-
const baseProps = {};
|
|
1026
|
-
if (!this.shadowRoot) {
|
|
1027
|
-
baseProps.onVnodeMounted = baseProps.onVnodeUpdated = this._renderSlots.bind(this);
|
|
1028
|
-
}
|
|
1029
|
-
const vnode = runtimeCore.createVNode(this._def, shared.extend(baseProps, this._props));
|
|
1030
|
-
if (!this._instance) {
|
|
1031
|
-
vnode.ce = (instance) => {
|
|
1032
|
-
this._instance = instance;
|
|
1033
|
-
instance.ce = this;
|
|
1034
|
-
instance.isCE = true;
|
|
1035
|
-
{
|
|
1036
|
-
instance.ceReload = (newStyles) => {
|
|
1037
|
-
if (this._styles) {
|
|
1038
|
-
this._styles.forEach((s) => this._root.removeChild(s));
|
|
1039
|
-
this._styles.length = 0;
|
|
1040
|
-
}
|
|
1041
|
-
this._applyStyles(newStyles);
|
|
1042
|
-
this._instance = null;
|
|
1043
|
-
this._update();
|
|
1044
|
-
};
|
|
1045
|
-
}
|
|
1046
|
-
const dispatch = (event, args) => {
|
|
1047
|
-
this.dispatchEvent(
|
|
1048
|
-
new CustomEvent(
|
|
1049
|
-
event,
|
|
1050
|
-
shared.isPlainObject(args[0]) ? shared.extend({ detail: args }, args[0]) : { detail: args }
|
|
1051
|
-
)
|
|
1052
|
-
);
|
|
1053
|
-
};
|
|
1054
|
-
instance.emit = (event, ...args) => {
|
|
1055
|
-
dispatch(event, args);
|
|
1056
|
-
if (shared.hyphenate(event) !== event) {
|
|
1057
|
-
dispatch(shared.hyphenate(event), args);
|
|
1058
|
-
}
|
|
1059
|
-
};
|
|
1060
|
-
this._setParent();
|
|
1061
|
-
};
|
|
1062
|
-
}
|
|
1063
|
-
return vnode;
|
|
1064
|
-
}
|
|
1065
1037
|
_applyStyles(styles, owner) {
|
|
1066
1038
|
if (!styles) return;
|
|
1067
1039
|
if (owner) {
|
|
@@ -1110,11 +1082,13 @@ class VueElement extends BaseClass {
|
|
|
1110
1082
|
_renderSlots() {
|
|
1111
1083
|
const outlets = this._getSlots();
|
|
1112
1084
|
const scopeId = this._instance.type.__scopeId;
|
|
1085
|
+
const slotReplacements = /* @__PURE__ */ new Map();
|
|
1113
1086
|
for (let i = 0; i < outlets.length; i++) {
|
|
1114
1087
|
const o = outlets[i];
|
|
1115
1088
|
const slotName = o.getAttribute("name") || "default";
|
|
1116
1089
|
const content = this._slots[slotName];
|
|
1117
1090
|
const parent = o.parentNode;
|
|
1091
|
+
const replacementNodes = [];
|
|
1118
1092
|
if (content) {
|
|
1119
1093
|
for (const n of content) {
|
|
1120
1094
|
if (scopeId && n.nodeType === 1) {
|
|
@@ -1127,12 +1101,19 @@ class VueElement extends BaseClass {
|
|
|
1127
1101
|
}
|
|
1128
1102
|
}
|
|
1129
1103
|
parent.insertBefore(n, o);
|
|
1104
|
+
replacementNodes.push(n);
|
|
1130
1105
|
}
|
|
1131
1106
|
} else {
|
|
1132
|
-
while (o.firstChild)
|
|
1107
|
+
while (o.firstChild) {
|
|
1108
|
+
const child = o.firstChild;
|
|
1109
|
+
parent.insertBefore(child, o);
|
|
1110
|
+
replacementNodes.push(child);
|
|
1111
|
+
}
|
|
1133
1112
|
}
|
|
1134
1113
|
parent.removeChild(o);
|
|
1114
|
+
slotReplacements.set(o, replacementNodes);
|
|
1135
1115
|
}
|
|
1116
|
+
this._updateSlotNodes(slotReplacements);
|
|
1136
1117
|
}
|
|
1137
1118
|
/**
|
|
1138
1119
|
* @internal
|
|
@@ -1189,13 +1170,76 @@ class VueElement extends BaseClass {
|
|
|
1189
1170
|
}
|
|
1190
1171
|
}
|
|
1191
1172
|
}
|
|
1173
|
+
class VueElement extends VueElementBase {
|
|
1174
|
+
constructor(def, props = {}, createAppFn = createApp) {
|
|
1175
|
+
super(def, props, createAppFn);
|
|
1176
|
+
}
|
|
1177
|
+
_needsHydration() {
|
|
1178
|
+
if (this.shadowRoot && this._createApp !== createApp) {
|
|
1179
|
+
return true;
|
|
1180
|
+
} else {
|
|
1181
|
+
if (this.shadowRoot) {
|
|
1182
|
+
runtimeCore.warn(
|
|
1183
|
+
`Custom element has pre-rendered declarative shadow root but is not defined as hydratable. Use \`defineSSRCustomElement\`.`
|
|
1184
|
+
);
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
return false;
|
|
1188
|
+
}
|
|
1189
|
+
_mount(def) {
|
|
1190
|
+
if (!def.name) {
|
|
1191
|
+
def.name = "VueElement";
|
|
1192
|
+
}
|
|
1193
|
+
this._app = this._createApp(def);
|
|
1194
|
+
this._inheritParentContext();
|
|
1195
|
+
if (def.configureApp) {
|
|
1196
|
+
def.configureApp(this._app);
|
|
1197
|
+
}
|
|
1198
|
+
this._app._ceVNode = this._createVNode();
|
|
1199
|
+
this._app.mount(this._root);
|
|
1200
|
+
}
|
|
1201
|
+
_update() {
|
|
1202
|
+
if (!this._app) return;
|
|
1203
|
+
const vnode = this._createVNode();
|
|
1204
|
+
vnode.appContext = this._app._context;
|
|
1205
|
+
render(vnode, this._root);
|
|
1206
|
+
}
|
|
1207
|
+
_unmount() {
|
|
1208
|
+
if (this._app) {
|
|
1209
|
+
this._app.unmount();
|
|
1210
|
+
}
|
|
1211
|
+
if (this._instance && this._instance.ce) {
|
|
1212
|
+
this._instance.ce = void 0;
|
|
1213
|
+
}
|
|
1214
|
+
this._app = this._instance = null;
|
|
1215
|
+
}
|
|
1216
|
+
/**
|
|
1217
|
+
* Only called when shadowRoot is false
|
|
1218
|
+
*/
|
|
1219
|
+
_updateSlotNodes(replacements) {
|
|
1220
|
+
}
|
|
1221
|
+
_createVNode() {
|
|
1222
|
+
const baseProps = {};
|
|
1223
|
+
if (!this.shadowRoot) {
|
|
1224
|
+
baseProps.onVnodeMounted = baseProps.onVnodeUpdated = this._renderSlots.bind(this);
|
|
1225
|
+
}
|
|
1226
|
+
const vnode = runtimeCore.createVNode(this._def, shared.extend(baseProps, this._props));
|
|
1227
|
+
if (!this._instance) {
|
|
1228
|
+
vnode.ce = (instance) => {
|
|
1229
|
+
this._instance = instance;
|
|
1230
|
+
this._processInstance();
|
|
1231
|
+
};
|
|
1232
|
+
}
|
|
1233
|
+
return vnode;
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1192
1236
|
function useHost(caller) {
|
|
1193
|
-
const
|
|
1194
|
-
const el =
|
|
1237
|
+
const { hasInstance, value } = runtimeCore.useInstanceOption("ce", true);
|
|
1238
|
+
const el = value;
|
|
1195
1239
|
if (el) {
|
|
1196
1240
|
return el;
|
|
1197
1241
|
} else {
|
|
1198
|
-
if (!
|
|
1242
|
+
if (!hasInstance) {
|
|
1199
1243
|
runtimeCore.warn(
|
|
1200
1244
|
`${caller || "useHost"} called without an active component instance.`
|
|
1201
1245
|
);
|
|
@@ -1214,12 +1258,12 @@ function useShadowRoot() {
|
|
|
1214
1258
|
|
|
1215
1259
|
function useCssModule(name = "$style") {
|
|
1216
1260
|
{
|
|
1217
|
-
const
|
|
1218
|
-
if (!
|
|
1261
|
+
const { hasInstance, value: type } = runtimeCore.useInstanceOption("type", true);
|
|
1262
|
+
if (!hasInstance) {
|
|
1219
1263
|
runtimeCore.warn(`useCssModule must be called inside setup()`);
|
|
1220
1264
|
return shared.EMPTY_OBJ;
|
|
1221
1265
|
}
|
|
1222
|
-
const modules =
|
|
1266
|
+
const modules = type.__cssModules;
|
|
1223
1267
|
if (!modules) {
|
|
1224
1268
|
runtimeCore.warn(`Current instance does not have CSS modules injected.`);
|
|
1225
1269
|
return shared.EMPTY_OBJ;
|
|
@@ -1879,12 +1923,15 @@ const initDirectivesForSSR = () => {
|
|
|
1879
1923
|
exports.Transition = Transition;
|
|
1880
1924
|
exports.TransitionGroup = TransitionGroup;
|
|
1881
1925
|
exports.VueElement = VueElement;
|
|
1926
|
+
exports.VueElementBase = VueElementBase;
|
|
1882
1927
|
exports.createApp = createApp;
|
|
1883
1928
|
exports.createSSRApp = createSSRApp;
|
|
1884
1929
|
exports.defineCustomElement = defineCustomElement;
|
|
1885
1930
|
exports.defineSSRCustomElement = defineSSRCustomElement;
|
|
1886
1931
|
exports.hydrate = hydrate;
|
|
1887
1932
|
exports.initDirectivesForSSR = initDirectivesForSSR;
|
|
1933
|
+
exports.nodeOps = nodeOps;
|
|
1934
|
+
exports.patchProp = patchProp;
|
|
1888
1935
|
exports.render = render;
|
|
1889
1936
|
exports.useCssModule = useCssModule;
|
|
1890
1937
|
exports.useCssVars = useCssVars;
|