-
Notifications
You must be signed in to change notification settings - Fork 2
/
utils.js
69 lines (65 loc) · 1.49 KB
/
utils.js
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
function getRadios(options) {
const { name, radios, target } = options;
return Object.entries(radios)
.map(
([value, group]) => `
<input class="${name}" type="radio" id="${name}-${group}-${value}" name="${group}" value="${value}">
<label for="${value}">${value}</label>
`
)
.join('');
}
function addWorkTrigger(element) {
const contain = 'contain';
var div = document.createElement('div');
const radios = {
none: contain,
size: contain,
layout: contain,
paint: contain,
content: contain,
strict: contain,
};
div.innerHTML = `
<div class="contain-target-wrapper">
${getRadios({
name: 'contain-attr',
target: '.contain-target',
radios,
})}
<div class="contain-target">
<div class="contain-content">⚙</div>
</div>
<pre data-styles="none">
contain: none;
</pre>
<pre data-styles="size">
width: px;
height: px;
contain: size;
</pre>
<pre data-styles="layout">
width: px;
height: px;
overflow: hidden;
contain: layout;
</pre>
<pre data-styles="paint">
width: px;
height: px;
contain: paint;
</pre>
<pre data-styles="content">
width: px;
height: px;
contain: content;
</pre>
<pre data-styles="strict">
width: px;
height: px;
contain: strict;
</pre>
</div>
`;
element.appendChild(div);
}