-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: Storybook HTML SimulatePageLoad.ts doesn't remove scripts on page change #28776
Comments
** Disclaimer** This information might be inaccurate, due to it being generated automatically
export function simulatePageLoad($container: any) {
let $scriptsRoot = document.getElementById(SCRIPTS_ROOT_ID);
if (!$scriptsRoot) {
$scriptsRoot = document.createElement('div');
$scriptsRoot.id = SCRIPTS_ROOT_ID;
document.body.appendChild($scriptsRoot);
} else {
// Clear existing scripts
while ($scriptsRoot.firstChild) {
$scriptsRoot.removeChild($scriptsRoot.firstChild);
}
}
const $scripts = Array.from($container.querySelectorAll(SCRIPT));
if ($scripts.length) {
const scriptsToExecute: any[] = [];
$scripts.forEach(($script: any) => {
const typeAttr = $script.getAttribute('type');
if (!typeAttr || runScriptTypes.includes(typeAttr)) {
scriptsToExecute.push((callback: any) => insertScript($script, callback, $scriptsRoot));
}
});
if (scriptsToExecute.length) {
insertScriptsSequentially(scriptsToExecute, simulateDOMContentLoaded, undefined);
}
} else {
simulateDOMContentLoaded();
}
} References/.github/DISCUSSION_TEMPLATE/help.yml
|
Simarilly if you write your injected script to listen to the simulated DOMContentLoaded when switching from a storie to an autodocs page it doesnt run the simulatePageLoad() api. |
Describe the bug
If you add a
script
tag to your story thestorybook/code/core/src/preview-api/modules/preview-web/simulate-pageload.ts
Line 91 in 0b6b357
Reproduction link
n/a
Reproduction steps
No response
System
Additional context
No response
The text was updated successfully, but these errors were encountered: