NodeIterator.whatToShow
read-only property represents an
unsigned integer
representing a bitmask signifying what types of nodes should be returned by the
NodeIterator
.
var nodeTypes = nodeIterator.whatToShow;
The values that can be combined to form the bitmask are:
| 常量 | 数值 | 描述 |
NodeFilter.SHOW_ALL
|
-1
(that is the max value of
unsigned long
)
|
展示所有节点。 |
NodeFilter.SHOW_ATTRIBUTE
|
2
|
Shows attribute
Attr
nodes. This is meaningful only when creating a
NodeIterator
or
TreeWalker
采用
Attr
node as its root; in this case, it means that the attribute node will appear in the first position of the iteration or traversal. Since attributes are never children of other nodes, they do not appear when traversing over the document tree.
|
NodeFilter.SHOW_CDATA_SECTION
|
8
|
展示
CDATASection
节点。
|
NodeFilter.SHOW_COMMENT
|
128
|
展示
注释
节点。
|
NodeFilter.SHOW_DOCUMENT
|
256
|
展示
Document
节点。
|
NodeFilter.SHOW_DOCUMENT_FRAGMENT
|
1024
|
展示
DocumentFragment
节点。
|
NodeFilter.SHOW_DOCUMENT_TYPE
|
512
|
展示
DocumentType
节点。
|
NodeFilter.SHOW_ELEMENT
|
1
|
展示
元素
节点。
|
NodeFilter.SHOW_ENTITY
|
32
|
展示
Entity
nodes. This is meaningful only when creating a
NodeIterator
or
TreeWalker
采用
Entity
node as its root; in this case, it means that the
Entity
node will appear in the first position of the traversal. Since entities are not part of the document tree, they do not appear when traversing over the document tree.
|
NodeFilter.SHOW_ENTITY_REFERENCE
|
16
|
展示
EntityReference
节点。
|
NodeFilter.SHOW_NOTATION
|
2048
|
展示
Notation
nodes. This is meaningful only when creating a
NodeIterator
or
TreeWalker
采用
Notation
node as its root; in this case, it means that the
Notation
node will appear in the first position of the traversal. Since entities are not part of the document tree, they do not appear when traversing over the document tree.
|
NodeFilter.SHOW_PROCESSING_INSTRUCTION
|
64
|
展示
ProcessingInstruction
节点。
|
NodeFilter.SHOW_TEXT
|
4
|
展示
文本
节点。
|
var nodeIterator = document.createNodeIterator(
document.body,
NodeFilter.SHOW_ELEMENT + NodeFilter.SHOW_COMMENT + NodeFilter.SHOW_TEXT,
{ acceptNode: function(node) { return NodeFilter.FILTER_ACCEPT; } },
false
);
if( (nodeIterator.whatToShow == NodeFilter.SHOW_ALL) ||
(nodeIterator.whatToShow % (NodeFilter.SHOW_COMMENT*2)) >= NodeFilter.SHOW_COMMENT) {
// nodeIterator will show comments
}
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
whatToShow
|
Chrome 1 | Edge 12 | Firefox 3.5 | IE 9 | Opera 9 | Safari 3 | WebView Android Yes | Chrome Android Yes | Firefox Android 4 | Opera Android 10.1 | Safari iOS 3 | Samsung Internet Android Yes |
完整支持
NodeIterator
.
NodeIterator
AbortController
AbortSignal
AbstractRange
Attr
ByteString
CDATASection
CSSPrimitiveValue
CSSValue
CSSValueList
CharacterData
ChildNode
注释
CustomEvent
DOMConfiguration
DOMError
DOMErrorHandler
DOMException
DOMImplementation
DOMImplementationList
DOMImplementationRegistry
DOMImplementationSource
DOMLocator
DOMObject
DOMParser
DOMPoint
DOMPointInit
DOMPointReadOnly
DOMRect
DOMString
DOMTimeStamp
DOMTokenList
DOMUserData
Document
DocumentFragment
DocumentType
元素
ElementTraversal
Entity
EntityReference
事件
EventTarget
HTMLCollection
MutationObserver
节点
NodeFilter
NodeList
NonDocumentTypeChildNode
ProcessingInstruction
PromiseResolver
范围
StaticRange
文本
TextDecoder
TextEncoder
TimeRanges
TreeWalker
TypeInfo
USVString
UserDataHandler
XMLDocument