-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Expand file tree
/
Copy pathdisplay-contents-blockify-dynamic.html
More file actions
72 lines (68 loc) · 3.4 KB
/
display-contents-blockify-dynamic.html
File metadata and controls
72 lines (68 loc) · 3.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<!doctype html>
<link rel="help" href="https://un5h208565ak8emkwgjjkgb49yug.julianrbryant.com/show_bug.cgi?id=1561283">
<link rel="help" href="https://un5n798jx6qx6j0rmf2verhh.julianrbryant.com/css-display/#valdef-display-contents">
<link rel="help" href="https://un5n798jx6qx6j0rmf2verhh.julianrbryant.com/css-grid/#grid-item-display">
<link rel="author" href="https://un5pc8f538pd6zm5.julianrbryant.com" title="Mozilla">
<link rel="author" href="mailto:emilio@crisal.io" title="Emilio Cobos Álvarez">
<link rel="author" href="mailto:obrufau@igalia.com" title="Oriol Brufau">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
.grid { display: grid }
</style>
<div style="display: grid">
<span id="grid-child">
<span></span>
</div>
</div>
<div id="grid-to-block" style="display: grid">
<div style="display: contents">
<div style="display: contents">
<button>button1</button>
<button id="deblockified">button2</button>
</div>
</div>
</div>
<div id="block-to-grid" style="display: block">
<div style="display: contents">
<div style="display: contents">
<button>button1</button>
<button id="blockified">button2</button>
</div>
</div>
</div>
<script>
function display(el) {
return getComputedStyle(el).display;
}
test(function() {
let child = document.getElementById("grid-child");
let grandChild = child.firstElementChild;
assert_equals(display(child), "block", "Grid child should get blockified");
assert_equals(display(grandChild), "inline", "Grid grand-child should not get initially blockified");
child.style.display = "contents";
assert_equals(display(child), "contents", "No reason for it not to become display: contents");
assert_equals(display(grandChild), "block", "Grid grand-child with display: contents parent should get blockified");
child.style.display = "";
assert_equals(display(child), "block", "Grid child should get blockified");
assert_equals(display(grandChild), "inline", "Grid grand-child should get un-blockified when its parent's display stops being `contents`");
}, "Dynamic changes to `display` causing blockification of children are handled correctly");
test(() => {
let gridToBlock = document.getElementById("grid-to-block");
let itemGrandChild = document.getElementById("deblockified");
assert_equals(display(gridToBlock), "grid", "Container should be a grid");
assert_equals(display(itemGrandChild), "block", "Item should have been blockified");
gridToBlock.style.display = "block";
assert_equals(display(gridToBlock), "block", "Container should become a block");
assert_equals(display(itemGrandChild), "inline-block", "Item should get de-blockified");
}, "Dynamic changes to `display` from `grid` to `block` should cause children to get de-blockified despite being children of `display: contents` elements");
test(() => {
let blockToGrid = document.getElementById("block-to-grid");
let itemGrandChild = document.getElementById("blockified");
assert_equals(display(blockToGrid), "block", "Container should be a block");
assert_equals(display(itemGrandChild), "inline-block", "Item should not have been blockified");
blockToGrid.style.display = "grid";
assert_equals(display(blockToGrid), "grid", "Container should become a grid");
assert_equals(display(itemGrandChild), "block", "Item should get blockified");
}, "Dynamic changes to `display` from `block` to `grid` should cause children to get blockified despite being children of `display: contents` elements")
</script>