mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-14 05:37:20 +03:00
chore(components): lazily create root to mount components if needed (#13778)
This commit is contained in:
parent
13224d1c9f
commit
4b6f53461d
@ -53,6 +53,11 @@ function render(component) {
|
||||
}
|
||||
|
||||
window.playwrightMount = component => {
|
||||
if (!document.getElementById('root')) {
|
||||
const rootElement = document.createElement('div');
|
||||
rootElement.id = 'root';
|
||||
document.body.append(rootElement);
|
||||
}
|
||||
ReactDOM.render(render(component), document.getElementById('root'));
|
||||
return '#root > *';
|
||||
};
|
||||
|
@ -26,6 +26,11 @@ export default (components, options) => {
|
||||
};
|
||||
|
||||
const playwrightMount = component => {
|
||||
if (!document.getElementById('root')) {
|
||||
const rootElement = document.createElement('div');
|
||||
rootElement.id = 'root';
|
||||
document.body.append(rootElement);
|
||||
}
|
||||
let componentCtor = registry.get(component.type);
|
||||
if (!componentCtor) {
|
||||
// Lookup by shorthand.
|
||||
|
@ -125,6 +125,11 @@ function createDevTools() {
|
||||
}
|
||||
|
||||
window.playwrightMount = async component => {
|
||||
if (!document.getElementById('root')) {
|
||||
const rootElement = document.createElement('div');
|
||||
rootElement.id = 'root';
|
||||
document.body.append(rootElement);
|
||||
}
|
||||
const app = instance.createApp({
|
||||
render: () => render(component)
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user