- From: <bugzilla@jessica.w3.org>
- Date: Wed, 15 Aug 2012 18:09:36 +0000
- To: www-dom@w3.org
https://www.w3.org/Bugs/Public/show_bug.cgi?id=18581
Summary: pre-insert and replace both check type of 'node' in
too many places
Product: WebAppsWG
Version: unspecified
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: DOM
AssignedTo: annevk@annevk.nl
ReportedBy: zackw@panix.com
QAContact: public-webapps-bugzilla@w3.org
CC: mike@w3.org, www-dom@w3.org
The pre-insert and replace algorithms
(http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#mutation-algorithms)
have this structure:
if (parent is not a Document, DocumentFragment, or Element)
throw HierarchyRequestError;
if (parent is a Document) {
if (node is not a DocumentFragment, DocumentType, Element,
ProcessingInstruction, or Comment)
throw HierarchyRequestError;
more checks;
}
else if (node is not a DocumentFragment, Element, Text,
ProcessingInstruction, or Comment)
throw HierarchyRequestError;
more operations;
It would be clearer if they had this structure instead:
if (parent is not a Document, DocumentFragment, or Element)
throw HierarchyRequestError;
if (node is not a DocumentFragment, DocumentType, Element, Text,
ProcessingInstruction, or Comment)
throw HierarchyRequestError;
if ((node is a Text and parent is a Document) or
(node is a DocumentType and parent is not a Document))
throw HierarchyRequestError;
if (parent is a Document)
more checks;
more operations;
Specifically, it would be clearer that most of the node type constraints apply
regardless of the type of 'parent', and there are just a couple of special
cases.
I would also recommend moving step 3 ("If child is not null...") of the
pre-insert algorithm to be step 1 (and pushing the current steps 1 and 2 down);
this would provide more parallel structure with the replace algorithm, and
would reduce the chance of confusing the reader about which of 'child' and
'node' is the new node.
I am happy to provide a proper patch to the prose if that would be helpful.
--
Configure bugmail: https://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
Received on Wednesday, 15 August 2012 18:09:37 UTC