about summary refs log tree commit diff stats
path: root/test/js/prev_next_parent_child.html
blob: 85abe7fe79652e80d89fae2a6482d34cfa9de269 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<!doctype html>
<main>
<div id=x>Fail</div>
test
<a id=y>test test</a>
</main>
<script>
(function() {
	let x = document.getElementById("x")
	let y = document.getElementById("y");
	if (y.previousSibling === x) return;
	if (y.previousSibling.textContent.trim() !== "test") return;
	if (y.previousElementSibling !== x) return;
	if (x.nextElementSibling !== y) return;
	if (x.nextSibling.textContent.trim() !== "test") return;
	x.nextSibling.remove();
	x.nextSibling.remove();
	if (x.parentElement.children.length !== 1) return;
	if (x.parentElement.children[0] !== x) return;
	x.textContent = "Success";
})()
</script>