You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/api.md
+12-7Lines changed: 12 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -413,29 +413,34 @@ store = await storage("my-data-store", storage_class=MyStorage)
413
413
414
414
### `pyscript.web`
415
415
416
-
TODO: Use `display(element)` not `element.display()`.
417
-
418
416
The classes and references in this namespace provide a Pythonic way to interact
419
417
with the DOM. An explanation for how to idiomatically use this API can be found
420
418
[in the user guide](../user-guide/dom/#pyscriptweb)
421
419
422
-
#### `pyscript.web.dom`
420
+
#### `pyscript.web.page`
423
421
424
-
This object has two attributes and a single method:
422
+
This object represents a web page. It has four attributes and two methods:
425
423
424
+
*`html` - a reference to a Python object representing the [document's html](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/html) root element.
426
425
*`head` - a reference to a Python object representing the [document's head](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/head).
427
426
*`body` - a reference to a Python object representing the [document's body](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/body).
427
+
*`title` - the page's [title](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/title) (usually displayed in the browser's title bar or a page's tab.
428
428
*`find` - a method that takes a single [selector](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_selectors)
429
429
argument and returns a collection of Python objects representing the matching
430
430
elements.
431
+
*`append` - a shortcut for `page.body.append` (to add new elements to the
432
+
page).
433
+
434
+
You may also shortcut the `find` method by enclosing a CSS selector in square
435
+
brackets: `page["#my-thing"]`.
431
436
432
437
These are provided as a convenience so you have several simple and obvious
433
-
options for accessing the content of the page (DOM).
438
+
options for accessing and changing the content of the page.
434
439
435
440
All the Python objects returned by these attributes and method are instances of
436
-
classes defined in the `pyscript.web.elements` namespace.
441
+
classes relating to HTML elements defined in the `pyscript.web` namespace.
437
442
438
-
#### `pyscript.web.elements.*`
443
+
#### `pyscript.web.*`
439
444
440
445
There are many classes in this namespace. Each is a one-to-one mapping of any
441
446
HTML element name to a Python class representing the HTML element of that
Copy file name to clipboardExpand all lines: docs/user-guide/dom.md
+30-28Lines changed: 30 additions & 28 deletions
Original file line number
Diff line number
Diff line change
@@ -99,39 +99,45 @@ There are three core concepts to remember:
99
99
The `find` API uses exactly the [same queries](https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model/Locating_DOM_elements_using_selectors)
100
100
as those used by native browser methods like `qurerySelector` or
101
101
`querySelectorAll`.
102
-
* Use classes in the `pyscript.web.elements` namespace to create and organise
102
+
* Use classes in the `pyscript.web` namespace to create and organise
103
103
new elements on the web page.
104
104
* Collections of elements allow you to access and change attributes en-mass.
105
105
Such collections are returned from `find` queries and are also used for the
0 commit comments