Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /html/semantics/tabular-data/the-table-element/parentless-props.html - WPT Dashboard Interop Dashboard
<!DOCTYPE HTML>
<title>Table cell and row properties when not in a table</title>
<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<template id="template1"><td></td></template>
<template id="template2"><tr></tr></template>
<script>
"use strict";
test(() => {
const td1 = document.createElement("td");
assert_equals(td1.cellIndex, -1);
const td2 = document.querySelector("#template1").content.querySelector("td");
assert_equals(td2.cellIndex, -1);
}, "td.cellIndex should return -1 when the td is not inside a tr");
test(() => {
const td1 = document.createElement("td");
assert_equals(td1.headers.length, 0);
const td2 = document.querySelector("#template1").content.querySelector("td");
assert_equals(td2.headers.length, 0);
}, "td.headers should return an empty DOMTokenList when the td is not inside a tr");
test(() => {
const tr1 = document.createElement("tr");
assert_equals(tr1.sectionRowIndex, -1);
const tr2 = document.querySelector("#template2").content.querySelector("tr");
assert_equals(tr2.sectionRowIndex, -1);
}, "tr.sectionRowIndex should return -1 when the tr is not inside a parent");
</script>