mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-22 03:35:31 -05:00
Allow nodes in shadow roots to be addressed via Element (#1454)
This commit is contained in:
committed by
GitHub
parent
82e5b64bad
commit
d3bcd87cfa
30
pyscriptjs/tests/integration/test_shadow_root.py
Normal file
30
pyscriptjs/tests/integration/test_shadow_root.py
Normal file
@@ -0,0 +1,30 @@
|
||||
from .support import PyScriptTest, skip_worker
|
||||
|
||||
|
||||
class TestShadowRoot(PyScriptTest):
|
||||
@skip_worker("FIXME: js.document")
|
||||
def test_reachable_shadow_root(self):
|
||||
self.pyscript_run(
|
||||
r"""
|
||||
<script>
|
||||
// reason to wait for py-script is that it's the entry point for
|
||||
// all patches and the MutationObserver, otherwise being this a synchronous
|
||||
// script the constructor gets instantly invoked at the node before
|
||||
// py-script gets a chance to initialize itself.
|
||||
customElements.whenDefined('py-script').then(() => {
|
||||
customElements.define('s-r', class extends HTMLElement {
|
||||
constructor() {
|
||||
super().attachShadow({mode: 'closed'}).innerHTML =
|
||||
'<div id="shadowed">OK</div>';
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<s-r></s-r>
|
||||
<py-script>
|
||||
import js
|
||||
js.console.log(Element("shadowed").innerHtml)
|
||||
</py-script>
|
||||
"""
|
||||
)
|
||||
assert self.console.log.lines[-1] == "OK"
|
||||
Reference in New Issue
Block a user