8000 Deprecate `py-mount` Attribute by JeffersGlass · Pull Request #1330 · pyscript/pyscript · GitHub
[go: up one dir, main page]

Skip to content

Deprecate py-mount Attribute #1330

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

Merged
merged 5 commits into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Deprecate py-mount
  • Loading branch information
JeffersGlass committed Mar 29, 2023
commit 412afd28b7352f6470c59b1e467facd37ba5b9b8
8 changes: 8 additions & 0 deletions docs/development/deprecation-cycle.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,11 @@ showWarning(`
</p>
`, "html")
```

## Deprecation History

This section tracks deprecations of specific features, both for historical record and to help the development team remember to actually remove deprecated features in future releases.

|Attribute/Object/Functionality|Deprecated In|Removed In|
|-|-|-|
|`py-mount` attribute | (Release following 2023.03.1) | -|
6 changes: 6 additions & 0 deletions pyscriptjs/src/components/pyscript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,12 @@ 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) {
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('_');
Expand Down
13 changes: 13 additions & 0 deletions pyscriptjs/tests/integration/test_01_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,3 +345,16 @@ def myfunc():
btn.click()
assert self.console.log.lines[-1] == "hello world!"
assert self.console.error.lines == []

def test_py_mount_shows_deprecation_warning(self):
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
0