chore(ct): vue resolve internal type errors (#29649)
This commit is contained in:
parent
7e502e91b2
commit
303d7fdac9
|
|
@ -88,6 +88,9 @@ function __pwCreateSlot(html) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string | string[]} slot
|
||||||
|
*/
|
||||||
function __pwSlotToFunction(slot) {
|
function __pwSlotToFunction(slot) {
|
||||||
if (typeof slot === 'string')
|
if (typeof slot === 'string')
|
||||||
return __pwCreateSlot(slot)();
|
return __pwCreateSlot(slot)();
|
||||||
|
|
@ -175,7 +178,11 @@ function __pwCreateComponent(component) {
|
||||||
return { Component: component.type, props, slots: lastArg, listeners };
|
return { Component: component.type, props, slots: lastArg, listeners };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {any} slots
|
||||||
|
*/
|
||||||
function __pwWrapFunctions(slots) {
|
function __pwWrapFunctions(slots) {
|
||||||
|
/** @type {import('vue').ComponentInternalInstance['slots']} */
|
||||||
const slotsWithRenderFunctions = {};
|
const slotsWithRenderFunctions = {};
|
||||||
if (!Array.isArray(slots)) {
|
if (!Array.isArray(slots)) {
|
||||||
for (const [key, value] of Object.entries(slots || {}))
|
for (const [key, value] of Object.entries(slots || {}))
|
||||||
|
|
@ -198,25 +205,27 @@ function __pwCreateWrapper(component) {
|
||||||
return wrapper;
|
return wrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
function __pwSetDevTools() {
|
||||||
* @returns {any}
|
__pwSetDevtoolsHook({
|
||||||
*/
|
|
||||||
function __pwCreateDevTools() {
|
|
||||||
return {
|
|
||||||
emit(eventType, ...payload) {
|
emit(eventType, ...payload) {
|
||||||
if (eventType === 'component:emit') {
|
if (eventType !== 'component:emit')
|
||||||
const [, componentVM, event, eventArgs] = payload;
|
return;
|
||||||
for (const [wrapper, listeners] of __pwAllListeners) {
|
|
||||||
if (wrapper.component !== componentVM)
|
const [, componentVM, event, eventArgs] = payload;
|
||||||
continue;
|
for (const [wrapper, listeners] of __pwAllListeners) {
|
||||||
const listener = listeners[event];
|
if (wrapper.component !== componentVM)
|
||||||
if (!listener)
|
continue;
|
||||||
return;
|
const listener = listeners[event];
|
||||||
listener(...eventArgs);
|
if (!listener)
|
||||||
}
|
return;
|
||||||
|
listener(...eventArgs);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
};
|
on() {},
|
||||||
|
off() {},
|
||||||
|
once() {},
|
||||||
|
appRecords: []
|
||||||
|
}, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
const __pwAppKey = Symbol('appKey');
|
const __pwAppKey = Symbol('appKey');
|
||||||
|
|
@ -230,7 +239,7 @@ window.playwrightMount = async (component, rootElement, hooksConfig) => {
|
||||||
return wrapper;
|
return wrapper;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
__pwSetDevtoolsHook(__pwCreateDevTools(), {});
|
__pwSetDevTools();
|
||||||
|
|
||||||
for (const hook of window.__pw_hooks_before_mount || [])
|
for (const hook of window.__pw_hooks_before_mount || [])
|
||||||
await hook({ app, hooksConfig });
|
await hook({ app, hooksConfig });
|
||||||
|
|
@ -242,13 +251,15 @@ window.playwrightMount = async (component, rootElement, hooksConfig) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
window.playwrightUnmount = async rootElement => {
|
window.playwrightUnmount = async rootElement => {
|
||||||
const app = /** @type {import('vue').App} */ (rootElement[__pwAppKey]);
|
/** @type {import('vue').App<Element> | undefined} */
|
||||||
|
const app = rootElement[__pwAppKey];
|
||||||
if (!app)
|
if (!app)
|
||||||
throw new Error('Component was not mounted');
|
throw new Error('Component was not mounted');
|
||||||
app.unmount();
|
app.unmount();
|
||||||
};
|
};
|
||||||
|
|
||||||
window.playwrightUpdate = async (rootElement, component) => {
|
window.playwrightUpdate = async (rootElement, component) => {
|
||||||
|
/** @type {import('vue').VNode | undefined} */
|
||||||
const wrapper = rootElement[__pwWrapperKey];
|
const wrapper = rootElement[__pwWrapperKey];
|
||||||
if (!wrapper)
|
if (!wrapper)
|
||||||
throw new Error('Component was not mounted');
|
throw new Error('Component was not mounted');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue