|
| 1 | +from __future__ import annotations |
| 2 | + |
| 3 | +from typing import Callable |
| 4 | + |
1 | 5 | from w3.python.core.type import DOMString
|
2 | 6 | from w3.python.core.fundamental_interface.Node import Node
|
3 | 7 | from w3.python.core.fundamental_interface.Node import NodeType
|
4 |
| -from w3.python.typing import _Document |
| 8 | +from w3.python.typing import * |
5 | 9 |
|
6 | 10 |
|
7 | 11 | class DOMImplementation:
|
@@ -53,10 +57,41 @@ class DocumentFragment(Node):
|
53 | 57 | """
|
54 | 58 |
|
55 | 59 | def __init__(self,
|
56 |
| - owner_document: _Document, |
| 60 | + owner_document: Document, |
57 | 61 | read_only: bool = False) -> None:
|
58 | 62 | super().__init__(owner_document=owner_document,
|
59 | 63 | node_type=NodeType.DOCUMENT_FRAGMENT_NODE,
|
60 | 64 | node_name='#document-fragment',
|
61 | 65 | node_value=None,
|
62 | 66 | read_only=read_only)
|
| 67 | + |
| 68 | + |
| 69 | +class Document(Node): |
| 70 | + """Interface Document |
| 71 | +
|
| 72 | + The `Document` interface represents the entire HTML or XML document. |
| 73 | + Conceptually, it is the root of the document tree, and provides the primary access to the document's data. |
| 74 | +
|
| 75 | + Since elements, text nodes, comments, processing instructions, etc. cannot exist outside the context of a `Document`, the `Document` interface also contains the factory methods needed to create these objects. |
| 76 | + The `Node` objects created have a `ownerDocument`` attribute which associates them with the `Document` within whose context they were created. |
| 77 | + """ |
| 78 | + |
| 79 | + doctype: _DocumentType |
| 80 | + implementation: DOMImplementation |
| 81 | + documentElement: _Element |
| 82 | + createElement: Callable[[Document, DOMString], _Element] |
| 83 | + createDocumentFragment: Callable[[Document], _DocumentFragment] |
| 84 | + createTextNode: Callable[[Document, DOMString], _Text] |
| 85 | + createComment: Callable[[Document, DOMString], _Comment] |
| 86 | + createCDATASection: Callable[[Document, DOMString], _CDATASection] |
| 87 | + createProcessingInstruction: Callable[[Document, DOMString, DOMString], _ProcessingInstruction] |
| 88 | + createAttribute: Callable[[Document, DOMString], _Attr] |
| 89 | + createEntityReference: Callable[[Document, DOMString], _EntityReference] |
| 90 | + getElementsByTagName: Callable[[Document, DOMString], _NodeList] |
| 91 | + |
| 92 | + def __init__(self, read_only: bool = False) -> None: |
| 93 | + super().__init__(owner_document=None, |
| 94 | + node_type=NodeType.DOCUMENT_NODE, |
| 95 | + node_name='#document', |
| 96 | + node_value=None, |
| 97 | + read_only=read_only) |
0 commit comments