W3C home > Mailing lists > Public > public-webapps@w3.org > July to September 2008

Re: [whatwg] WebIDL and HTML5

From: Garrett Smith <dhtmlkitchen@gmail.com>
Date: Tue, 26 Aug 2008 20:12:55 -0700
Message-ID: <c9e12660808262012n277b19fdvce114b70a8c3a2b6@mail.gmail.com>
To: "Boris Zbarsky" <bzbarsky@mit.edu>
Cc: "Web Applications Working Group WG" <public-webapps@w3.org>

On Tue, Aug 26, 2008 at 8:04 PM, Boris Zbarsky <bzbarsky@mit.edu> wrote:
> Garrett Smith wrote:
>> Null is not the empty string.
> No one claimed that it was. A number of DOM methods are specified as
> treating them equivalently, however.

Well, I'm not so sure. I corresponded with Jonas who indicated that he
though null should convert to "". Now Maciej seems to be confused
about textContent = null. The result should be no effect.

And we can see that the implementation of textContent = null "feature"
was not per spec in Firefox or Webkit, so it is apparently quite

I have created a demo which expects that setting textContent to null
will have no effect, as per DOM Core 3. The deom does not take into my
opinion that setting textContent to null should result in the
textContent being "null"

<html lang="en">
	<title>Setting textContent to null</title>
<link rel="help"
<link rel="author" title="Garrett Smith" href="mailto:dhtmlkitchen@gmail.com"/>
<style type="text/css">
    #pass {
        display: none;
        background: #0F0;
    #fail {
        display: none;
        background: #F00;
<div id="el">this is the test node.</div>
var el = document.getElementById('el');
var orig = el.textContent;

function fail() {
  var f = document.getElementById('fail');
  var found = el.textContent;
  f.style.display = "inline-block";
  f.textContent += ": expected '" + orig + "'" +
  ", found '" + found + "' (" + (typeof found) + ")";
function reset() {
	el.textContent = orig;
clicks = [];
function checkPass(i) {
  clicks[i] = 1;
  if(clicks[1] && clicks[2])
    document.getElementById('pass').style.display = "inline-block";

<button onclick="reset();el.textContent;el.textContent = null;
	if(el.textContent!=orig)fail();else checkPass(1);">el.textContent =
<button onclick="reset();el.textContent =
'';checkPass(1);">el.textContent = ''</button>
<button onclick="reset();el.textContent = undefined;">el.textContent =

<div id="fail">FAIL</div>

 Firefox 3.1, Webkit
  FAIL: expected 'this is the test node.', found '' (string)
  FAIL: expected 'this is the test node.', found 'null' (string)

I feel that Opera's behavior is ideal, even though it is non-standard.
I would like to ask that the DOM 3 recommendation to be changed so
that setting textContent = null sets the textContent to have the
string value "null". Reasons:
1) Widespread inconsistencies.
2) A feature not relied on (likely to break few, if any existing sites)
3) Would make debugging easier


> -Boris
Received on Wednesday, 27 August 2008 03:13:30 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 16:07:17 UTC