David Wendt
a80aab1b08
Document roots can store an attributes object, even though they don't have attributes
2020-01-04 19:00:40 -05:00
David Wendt
6a472d32bb
Filter incompatible nodes from the sibling and child lists.
2020-01-04 19:00:39 -05:00
David Wendt
fd14d0c9df
Doctype nodes should be represented as text nodes to ActionScript (if they somehow grab hold of them)
2020-01-04 19:00:38 -05:00
David Wendt
6b4bbee195
Create and store `DocType` nodes on the tree when we encounter a `<!DOCTYPE...>` tag.
2020-01-04 19:00:38 -05:00
David Wendt
aa749dc1b0
Store the XML document version, encoding, and standalone flags.
2020-01-04 19:00:38 -05:00
David Wendt
a869107480
The `DocumentRoot` node type should have it's own node type ID, and AS2 XML should filter it out. This also filters out comment nodes as text, which isn't technically wrong but we should do better
2020-01-04 19:00:37 -05:00
David Wendt
7965045d87
Add test for XMLNode.toString.
2020-01-04 19:00:37 -05:00
David Wendt
673f85f067
XMLNode type 1 is an element, not a text node.
2020-01-04 19:00:36 -05:00
David Wendt
88aa5f8004
Add extra whitespace to empty tags.
2020-01-04 19:00:36 -05:00
David Wendt
0c7a1fe667
Text and comment nodes are stored plain and must be escaped for XML
2020-01-04 19:00:36 -05:00
David Wendt
c7e1f34a5d
Print empty nodes as empty tags rather than start/end
2020-01-04 19:00:35 -05:00
David Wendt
c76e5ce447
appendChild also refuses to orphan nodes already part of another XML tree.
2020-01-04 19:00:35 -05:00
David Wendt
bff851e6a4
Add test for insertBefore
2020-01-04 19:00:34 -05:00
David Wendt
34cbe2e04b
insertNode rejects child nodes that already have a parent
2020-01-04 19:00:34 -05:00
David Wendt
7b4a509ebc
Avoid double-borrows when moving a child within it's parent
2020-01-04 19:00:33 -05:00
David Wendt
7753e20fe3
Add a test for XML.removeNode().
2020-01-04 19:00:33 -05:00
David Wendt
30266b2ce7
remove_child should also ensure the child disowns the parent.
2020-01-04 19:00:33 -05:00
David Wendt
8c5dcfe662
Swap in newly constructed nodes *before* filling them with content.
...
Fixes a bug where new XML("<node />").childNode[0].parentNode did NOT refer to the overall document object, but to a phantom text node.
This is because the swap operation used to construct an XMLObject's node in-place was happening AFTER parsing, which means that referents already existed to the temporary XMLNode created by XMLObject::new. swap is not to be called after tree structure has been created; it does not update referents to the swapped nodes.
In the future I should examine the implications of explicitly reconstructing already existing nodes, e.g. through XML.apply(some_xml). Right now, the existing node will be swapped with a new one, and two nodes will exist pointing to the same script object, which is a huge problem with our overall design. We should, at the very least, disassociate swapped nodes from their script object, just in case they still have referents.
Ideally, we wouldn't have to swap nodes, but to avoid a swap, I'd have to instead have a second layer of indirection just to hold a rewritable pointer that every XMLObject points to. This isn't really worth it unless I HAVE to do it, so I'm not going to do it.
2020-01-04 19:00:32 -05:00
David Wendt
568d90f4dc
Warn if XML.removeNode fails for whatever reason
2020-01-04 19:00:32 -05:00
David Wendt
1577f51730
Expose elided objects as pointers when debugging XML nodes
2020-01-04 19:00:32 -05:00
David Wendt
19ca11b08c
Impl `toString`
2020-01-04 19:00:31 -05:00
David Wendt
513460e4e0
Implement `insertBefore`
2020-01-04 19:00:31 -05:00
David Wendt
b0dce445b0
Impl `removeNode`
2020-01-04 19:00:29 -05:00
David Wendt
00319f14a8
Implement `namespaceURI`
2020-01-04 19:00:29 -05:00
David Wendt
73da72db98
Add a test for `appendChild`.
2020-01-04 19:00:28 -05:00
David Wendt
7c95eff048
Flag an error if we accidentally introduce a second script object by accident.
2020-01-04 19:00:28 -05:00
David Wendt
abb2690367
When constructing new XML nodes or documents, always ensure that the new node we swap in is properly linked to the same script object so that we don't accidentally recreate them.
2020-01-04 19:00:28 -05:00
David Wendt
8939dae90c
Implement `XMLNode.attributes` w/ read tests
2020-01-04 19:00:27 -05:00
David Wendt
6f48f3436f
Expose `previousSibling` and `nextSibling` to ActionScript.
...
This commit also fixes a bug caused by excessive use of copypaste, which was detected by the included test.
2020-01-04 19:00:25 -05:00
David Wendt
223320c98c
Expose `parentNode` to ActionScript
2020-01-04 19:00:24 -05:00
David Wendt
807725d7aa
Expose `firstChild` and `lastChild` to ActionScript w/ tests
2020-01-04 19:00:24 -05:00
David Wendt
1d1e493e0e
Refactor the child adoption process to ensure the child also adopts it's siblings.
2020-01-04 19:00:23 -05:00
David Wendt
48d68bebc4
Implement `hasChildNodes()` and add test
2020-01-04 19:00:23 -05:00
David Wendt
c58e866236
Add test for `cloneNode`
2020-01-04 19:00:22 -05:00
David Wendt
881dcb76ab
`cloneNode` without arguments is morally equivalent to `false`
2020-01-04 19:00:21 -05:00
David Wendt
8e33566d07
Add namespacing test
2020-01-04 19:00:21 -05:00
David Wendt
69a1ab1649
Expose namespace prefix and URI lookups to ActionScript.
...
Also, fix the previous commit's half-assed impl.
2020-01-04 19:00:20 -05:00
David Wendt
fe7d2b5173
Extremely WIP impl of `lookup_uri_for_namespace`
2020-01-04 19:00:20 -05:00
David Wendt
55fa6ef09b
Add node cloning support
2020-01-04 19:00:19 -05:00
David Wendt
37f6efb753
Expose `appendChild` to ActionScript
2020-01-04 19:00:19 -05:00
David Wendt
08c0f273a6
Add sibling links to nodes.
2020-01-04 19:00:18 -05:00
David Wendt
7e45dee8cf
Clippy said so.
2020-01-04 19:00:18 -05:00
David Wendt
eec449422b
`XMLDocument.roots` is not necessary since you can just get the children of it's node form anyway...
2020-01-04 19:00:18 -05:00
David Wendt
f8f569440f
Add very basic XML test
2020-01-04 19:00:17 -05:00
David Wendt
cfacd397cf
Most XML properties return `null`, not `undefined`.
...
Furthermore, `prefix` does not distinguish between `<test>` and `<:test>` - they both have a `prefix` of `""`.
2020-01-04 19:00:17 -05:00
David Wendt
b491dd034e
Don't overflow stack when debug-printing an entire document, either.
2020-01-04 19:00:16 -05:00
David Wendt
e47a1d1e38
Fix newly constructed XML trees not actually containing the XML they just parsed.
2020-01-04 19:00:16 -05:00
David Wendt
960e4dad90
Don't cause stack overflow when debug-printing XML nodes.
2020-01-04 19:00:16 -05:00
David Wendt
bec60acc1e
`XML.prototype` should be an `XMLObject` so that instances of `XML` can hold a node
2020-01-04 19:00:15 -05:00
David Wendt
d058c83ac0
Document roots should accept children.
2020-01-04 19:00:15 -05:00