Created PyScript alternative to document.queryselectorAll()
Now with this patch you can get a list of Element Objects from the Elements class,using CSS selectors(implemented with queryselectorAll()).There is still only one drawback: for mantaining Element class compatibility for elements without an id is given one #674 I also made a working example here https://github.com/LoreBadTime/PyScript_various_projects/blob/main/index.html You can see how it works in the first page of https://lorebadtime.github.io/PyScript_various_projects/
I just noticed that getting again the same elements list could be weird if a attribute is removed from an element in the list, to fix this there are two solutions:
-
updatemethod that updates the list elements (more performance efficient) -
elementsproperty modified to update the list every time is called
Its just an implementation choice and could be easily implemented
@LoreBadTime thanks for this PR. It's a great topic for discussion.
The core team actually discussed "what should we provide" as part of pyscript-core itself, what should be treated as stdlib and what should be an optional package. We were converging to the idea that pyscript-core itself should probably not provide an interface to the DOM right now and we should rather have a very simple interface (better than what we have right now) as part of the stdlib we provide. As other packages implement different approaches and things evolve in the stdlib, solutions can migrate from one to another 3rd party -> stdlib -> core.
So... we'll soon change the API we provide in PyScript itself and put it in a stdlib module (probably will deprecate the current Element in favor of that, allowing a few cycles for users to adapt their code).
For these reasons, I'd wait a bit on this PR. Hope it makes sense
Thank you for your PR contribution to PyScript. We are closing PRs older than 90 days with limited activity.