<要素>.textContent = undefined

DOM 操作である <要素>.textContent = undefined すると、何が入るのだろうか。あるいは、 null を代入すると、どうなるか。色々なパターンを、色々なブラウザで調べた。

生成元: http://0mg.github.io/etc/textcont.html

  1. 行の見出しセルは、代入の仕方 および 代入した値 を示している。
  2. 列の見出しセルは、代入後、どのプロパティにアクセスしたかを示している。
  3. ふつうのセルは、どんな値が返ってきたかを示している。
  4. 空欄のセルは、ブラウザでサポートしていないプロパティであるか、!p.hasChildNodes() である。

Opera

Opera/9.80 (Windows NT 5.1) Presto/2.12.388 Version/12.15
p.firstChild.nodeValuep.textContentp.innerText
p.firstChild.nodeValue = undefined(string) "undefined"(string) "undefined"(string) "undefined"
p.textContent = undefined(string) "undefined"(string) "undefined"(string) "undefined"
p.innerText = undefined(string) "undefined"(string) "undefined"(string) "undefined"
p.firstChild.nodeValuep.textContentp.innerText
p.firstChild.nodeValue = null(string) "null"(string) "null"(string) "null"
p.textContent = null(string) ""(string) ""
p.innerText = null(string) ""(string) ""

Firefox

Mozilla/5.0 (Windows NT 5.1; rv:20.0) Gecko/20100101 Firefox/20.0
p.firstChild.nodeValuep.textContentp.innerText
p.firstChild.nodeValue = undefined(string) ""(string) ""
p.textContent = undefined(string) ""
p.innerText = undefined(string) ""
p.firstChild.nodeValuep.textContentp.innerText
p.firstChild.nodeValue = null(string) ""(string) ""
p.textContent = null(string) ""
p.innerText = null(string) ""

Comodo Dragon

Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.2.2.0 Safari/537.31
p.firstChild.nodeValuep.textContentp.innerText
p.firstChild.nodeValue = undefined(string) "undefined"(string) "undefined"(string) "undefined"
p.textContent = undefined(string) "undefined"(string) "undefined"(string) "undefined"
p.innerText = undefined(string) "undefined"(string) "undefined"(string) "undefined"
p.firstChild.nodeValuep.textContentp.innerText
p.firstChild.nodeValue = null(string) ""(string) ""(string) ""
p.textContent = null(string) ""(string) ""
p.innerText = null(string) ""(string) ""

Internet Explorer 8

Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)
p.firstChild.nodeValuep.textContentp.innerText
p.firstChild.nodeValue = undefined(string) ""(string) ""
p.textContent = undefined(string) ""
p.innerText = undefined(string) "undefined"(string) "undefined"
p.firstChild.nodeValuep.textContentp.innerText
p.firstChild.nodeValue = null(string) "null"(string) "null"
p.textContent = null(string) ""
p.innerText = null(string) "null"(string) "null"