mirror of
https://github.com/pyscript/pyscript.git
synced 2026-04-05 05:00:30 -04:00
The all-new, pyscript.web (ignore the branch name :) ) (#2129)
* Minor cleanups: move all Element classes to bottom of module. * Commenting. * Commenting. * Commenting. * Group dunder methods. * Don't cache the element's parent. * Remove style type check until we decide whether or not to add for classes too. * Add ability to register/unregister element classes. * Implement __iter__ for container elements. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Minor renaming to make it clear when we have an Element instance vs an actual DOM element. * remove duplication: added Element.get_tag_name * Commenting. * Allow Element.append to 1) use *args, 2) accept iterables * Remove iterable check - inteferes with js proxies. * Don't use *args, so it quacks more like a list ;) * Element.append take 2 :) * Remove unused code. * Move to web.py with a page object! * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Added 'page.title' too :) * Add __getitem__ as a shortcut for page.find * Add Element.__getitem__ to be consistent * Make __getitem__ consistent for Page, Element and ElementCollection. * Docstringing. * Docstringing. * Docstringing/commenting. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix select.add (revert InnerHTML->html) * Commenting. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Hand-edit some of the AI :) * Rename ElementCollection.children -> ElementCollection.elements * Remove unnecessary guard. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -101,11 +101,9 @@ class TestElements(PyScriptTest):
|
||||
code_ = f"""
|
||||
from pyscript import when
|
||||
<script type="{interpreter}">
|
||||
from pyscript.web import dom
|
||||
from pyscript.web.elements import {el_type}
|
||||
|
||||
from pyscript.web import page, {el_type}
|
||||
el = {el_type}({attributes})
|
||||
dom.body.append(el)
|
||||
page.body.append(el)
|
||||
</script>
|
||||
"""
|
||||
self.pyscript_run(code_)
|
||||
@@ -620,13 +618,12 @@ class TestElements(PyScriptTest):
|
||||
code_ = f"""
|
||||
from pyscript import when
|
||||
<script type="{interpreter}">
|
||||
from pyscript.web import dom
|
||||
from pyscript.web.elements import div, p
|
||||
from pyscript.web import page, div, p
|
||||
|
||||
el = div("{div_text_content}")
|
||||
child = p('{p_text_content}')
|
||||
el.append(child)
|
||||
dom.body.append(el)
|
||||
page.body.append(el)
|
||||
</script>
|
||||
"""
|
||||
self.pyscript_run(code_)
|
||||
@@ -664,14 +661,13 @@ class TestElements(PyScriptTest):
|
||||
from pyscript import when
|
||||
<script type="{interpreter}">
|
||||
from pyscript import document
|
||||
from pyscript.web import dom
|
||||
from pyscript.web.elements import div, p
|
||||
from pyscript.web import page, div, p
|
||||
|
||||
el = div("{div_text_content}")
|
||||
child = document.createElement('P')
|
||||
child.textContent = '{p_text_content}'
|
||||
el.append(child)
|
||||
dom.body.append(el)
|
||||
page.body.append(el)
|
||||
</script>
|
||||
"""
|
||||
self.pyscript_run(code_)
|
||||
@@ -709,15 +705,14 @@ class TestElements(PyScriptTest):
|
||||
code_ = f"""
|
||||
from pyscript import when
|
||||
<script type="{interpreter}">
|
||||
from pyscript.web import dom
|
||||
from pyscript.web.elements import div, p, ElementCollection
|
||||
from pyscript.web import page, div, p, ElementCollection
|
||||
|
||||
el = div("{div_text_content}")
|
||||
child1 = p('{p_text_content}')
|
||||
child2 = p('{p2_text_content}', id='child2')
|
||||
collection = ElementCollection([child1, child2])
|
||||
el.append(collection)
|
||||
dom.body.append(el)
|
||||
page.body.append(el)
|
||||
</script>
|
||||
"""
|
||||
self.pyscript_run(code_)
|
||||
@@ -765,20 +760,19 @@ class TestElements(PyScriptTest):
|
||||
from pyscript import when
|
||||
<script type="{interpreter}">
|
||||
from pyscript import document
|
||||
from pyscript.web import dom
|
||||
from pyscript.web.elements import div, p, ElementCollection
|
||||
from pyscript.web import page, div, p, ElementCollection
|
||||
|
||||
el = div("{div_text_content}")
|
||||
child1 = p('{p_text_content}')
|
||||
child2 = p('{p2_text_content}', id='child2')
|
||||
|
||||
dom.body.append(child1)
|
||||
dom.body.append(child2)
|
||||
page.body.append(child1)
|
||||
page.body.append(child2)
|
||||
|
||||
nodes = document.querySelectorAll('p')
|
||||
el.append(nodes)
|
||||
|
||||
dom.body.append(el)
|
||||
page.body.append(el)
|
||||
</script>
|
||||
"""
|
||||
self.pyscript_run(code_)
|
||||
|
||||
Reference in New Issue
Block a user