mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-21 03:05:38 -05:00
Restore output attribute of py-script tags, add py-script exec lifecycle hooks (#1063)
* Add beforePyScriptExec, afterPyScriptExec lifecycle hooks * Add stdiodirector plugin for `output`, `stderr` attributes of py-script tag * Add docs on `output` and `stderr` attributes of py-script tag * Tests * Removed output deprecation warning for `output` attribute * Add createSingularWarning(), with createDeprecationWarning as alias
This commit is contained in:
@@ -111,10 +111,22 @@ export function joinPaths(parts: string[], separator = '/') {
|
||||
}
|
||||
|
||||
export function createDeprecationWarning(msg: string, elementName: string): void {
|
||||
createSingularWarning(msg, elementName);
|
||||
}
|
||||
|
||||
/** Adds a warning banner with content {msg} at the top of the page if
|
||||
* and only if no banner containing the {sentinelText} already exists.
|
||||
* If sentinelText is null, the full text of {msg} is used instead
|
||||
*
|
||||
* @param msg {string} The full text content of the warning banner to be displayed
|
||||
* @param sentinelText {string} [null] The text to match against existing warning banners.
|
||||
* If null, the full text of 'msg' is used instead.
|
||||
*/
|
||||
export function createSingularWarning(msg: string, sentinelText: string | null = null): void {
|
||||
const banners = document.getElementsByClassName('alert-banner py-warning');
|
||||
let bannerCount = 0;
|
||||
for (const banner of banners) {
|
||||
if (banner.innerHTML.includes(elementName)) {
|
||||
if (banner.innerHTML.includes(sentinelText ? sentinelText : msg)) {
|
||||
bannerCount++;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user