summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/dom/elements/global-attributes/translate-inherit-no-parent-element.html
blob: 370225c7f72a9e279eb068e7d34d292469cb47a5 (plain)
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
<!doctype html>
<meta charset=utf-8>
<title>The translate attribute inherit state when there's no parent element</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(() => {
  const div = document.createElement("div");
  assert_true(div.translate);
}, 'No parent node');

test(() => {
  const div = document.createElement("div");
  const frag = document.createDocumentFragment();
  frag.append(div);
  assert_true(div.translate);
}, 'DocumentFragment parent node');

for (const translateValue of ['yes', 'no']) {
  test(() => {
    const div = document.createElement("div");
    const myElement = document.createElement("my-element");
    myElement.setAttribute('translate', translateValue);
    myElement.attachShadow({mode: 'open'});
    myElement.shadowRoot.append(div);
    assert_true(div.translate);
  }, `ShadowRoot parent node whose shadow host has translate=${translateValue}`);
}

test(() => {
  assert_true(document.documentElement.translate);
}, 'Document parent node');
</script>