Implement document.queryselectorall()
Checklist
- [X] I added a descriptive title
- [X] I searched for other feature requests and couldn't find a duplicate (including also the
type-featuretag) - [X] I confirmed that it's not related to another project area (see the above section)
What is the idea?
If is needed to add a class to multiple elements or do something to multiple things,is needed the use of js
Like this
for e in document.querySelectorAll("#main > *"): e.classList.add("load")
`
Why is this needed
Isn't a pure python library call
What should happen?
Return a list of elements Maybe using a static method
Additional Context
No response
Done something here #702
All of the js global objects are exposed in the js module within Pyodide.
Here is an example that loops over results from document.querySelectorAll("#main > *")
example:
<html>
<head>
<link rel="stylesheet" href="https://pyscript.net/unstable/pyscript.css" />
<script defer src="https://pyscript.net/unstable/pyscript.js"></script>
</head>
<body>
<div id="main">
<div>ch0</div>
<div>ch1</div>
<div>ch2</div>
<div>ch3</div>
<div>ch4</div>
</div>
<py-script>
import js
elements = js.document.querySelectorAll("#main > *")
for element in elements:
print(element)
</py-script>
</body>
</html>
@tedpatrick should we close this then? https://github.com/pyscript/pyscript/pull/702 Seems like your solution is all-encompassing.