mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-19 18:27:29 -05:00
Deprecate py-mount Attribute (#1330)
* Deprecate py-mount attribute, with comments as to when it was deprecated * Add changelog entry for deprecation * Fix 'unused' examples that used py-mount (handtrack and mario)
This commit is contained in:
@@ -237,6 +237,13 @@ export async function mountElements(interpreter: InterpreterClient) {
|
||||
const matches: NodeListOf<HTMLElement> = document.querySelectorAll('[py-mount]');
|
||||
logger.info(`py-mount: found ${matches.length} elements`);
|
||||
|
||||
if (matches.length > 0) {
|
||||
//last non-deprecated version: 2023.03.1
|
||||
const deprecationMessage =
|
||||
'The "py-mount" attribute is deprecated. Please add references to HTML Elements manually in your script.';
|
||||
createDeprecationWarning(deprecationMessage, 'py-mount');
|
||||
}
|
||||
|
||||
let source = '';
|
||||
for (const el of matches) {
|
||||
const mountName = el.getAttribute('py-mount') || el.id.split('-').join('_');
|
||||
|
||||
@@ -345,3 +345,17 @@ class TestBasic(PyScriptTest):
|
||||
btn.click()
|
||||
assert self.console.log.lines[-1] == "hello world!"
|
||||
assert self.console.error.lines == []
|
||||
|
||||
def test_py_mount_shows_deprecation_warning(self):
|
||||
# last non-deprecated version: 2023.03.1
|
||||
self.pyscript_run(
|
||||
"""
|
||||
<div id="foo" py-mount></div>
|
||||
"""
|
||||
)
|
||||
banner = self.page.locator(".alert-banner")
|
||||
expected_message = (
|
||||
'The "py-mount" attribute is deprecated. '
|
||||
+ "Please add references to HTML Elements manually in your script."
|
||||
)
|
||||
assert banner.inner_text() == expected_message
|
||||
|
||||
Reference in New Issue
Block a user