Skip to content

Commit 59f510e

Browse files
authored
Update compareDocumentPosition index.md (mdn#43500)
1 parent a5acd8d commit 59f510e

File tree

1 file changed

+5
-13
lines changed
  • files/en-us/web/api/node/comparedocumentposition

1 file changed

+5
-13
lines changed

files/en-us/web/api/node/comparedocumentposition/index.md

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ browser-compat: api.Node.compareDocumentPosition
88

99
{{APIRef("DOM")}}
1010

11-
The **`compareDocumentPosition()`** method of the {{domxref("Node")}} interface
12-
reports the position of its argument node relative to the node on which it is called.
11+
The **`compareDocumentPosition()`** method of the {{domxref("Node")}} interface reports the position of its argument node relative to the node on which it is called.
1312

1413
## Syntax
1514

@@ -24,9 +23,7 @@ compareDocumentPosition(otherNode)
2423

2524
### Return value
2625

27-
An integer value representing `otherNode`'s position relative to `node`
28-
as a [bitmask](<https://en.wikipedia.org/wiki/Mask_(computing)>) combining the
29-
following constant properties of {{domxref("Node")}}:
26+
An integer value representing `otherNode`'s position relative to `node` as a [bitmask](<https://en.wikipedia.org/wiki/Mask_(computing)>) combining the following constant properties of {{domxref("Node")}} or `0` if `otherNode` is the same as this node:
3027

3128
- `Node.DOCUMENT_POSITION_DISCONNECTED` (`1`)
3229
- : Both nodes are in different documents or different trees in the same document.
@@ -41,11 +38,8 @@ following constant properties of {{domxref("Node")}}:
4138
- `Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC` (`32`)
4239
- : The result relies upon arbitrary and/or implementation-specific behavior and is not guaranteed to be portable.
4340

44-
Zero or more bits can be set, depending on which scenarios apply. For example, if
45-
`otherNode` is located earlier in the document **_and_**
46-
contains the node on which `compareDocumentPosition()` was
47-
called, then both the `DOCUMENT_POSITION_CONTAINS` and
48-
`DOCUMENT_POSITION_PRECEDING` bits would be set, producing a value of `10` (`0x0A`).
41+
Zero or more bits can be set, depending on which scenarios apply.
42+
For example, if `otherNode` is located earlier in the document **_and_** contains the node on which `compareDocumentPosition()` was called, then both the `DOCUMENT_POSITION_CONTAINS` and `DOCUMENT_POSITION_PRECEDING` bits would be set, producing a value of `10` (`0x0A`).
4943

5044
## Example
5145

@@ -61,9 +55,7 @@ if (head.compareDocumentPosition(body) & Node.DOCUMENT_POSITION_FOLLOWING) {
6155
```
6256

6357
> [!NOTE]
64-
> Because the result returned by `compareDocumentPosition()` is a bitmask,
65-
> the [bitwise AND operator](/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_AND)
66-
> must be used for meaningful results.
58+
> Because the result returned by `compareDocumentPosition()` is a bitmask, the [bitwise AND operator](/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_AND) must be used for meaningful results.
6759
6860
## Specifications
6961

0 commit comments

Comments
 (0)