Closed pshaughn closed 1 week ago
Do all major browsers currently throw InvalidNodeTypeError?
Chrome, Firefox, and Edge do; Safari might not. https://wpt.fyi/results/selection/selectAllChildren.html?label=experimental&label=master&aligned has many cases involving a doctype.
The specification already requires throwing InvalidNodeTypeError
. Not directly, but indirectly. The specification has steps that say things like “set the start of newRange” and those steps will throw InvalidNodeTypeError
because that’s part of the set the start or end algorithm from the DOM specification.
Regarding the ordering of the checks, see also my comments in #124.
Just looked at the WPT test and unfortunately it makes does the DOCUMENT_TYPE_NODE
check before making the document.contains check, so it expects behavior different from what the specification currently requires.
Various methods that take a node and offset are specified as throwing IndexSizeError if the offset exceeds the node's length. By WPT tests and by analogy with Range methods, these also need to throw InvalidNodeTypeError if the node is a DocumentType, and InvalidNodeType is the condition to check first for cases where both apply.