[whatwg] Fake Code

Garrett Smith dhtmlkitchen at gmail.com
Tue Jul 29 23:46:25 PDT 2008


Examples should work.

Citation from:
http://www.whatwg.org/specs/web-apps/current-work/#outlines

------------------------------------------------------------------------
The following JavaScript function shows how the tree walk could be
implemented. The root argument is the root of the tree to walk, and
the enter and exit arguments are callbacks that are called with the
nodes as they are entered and exited. [ECMA262]

function (root, enter, exit) {
  var node = root;
  start: do while (node) {
    enter(node);
    if (node.firstChild) {
      node = node.firstChild;
      continue start;
    }
    while (node) {
      exit(node);
      if (node.nextSibling) {
        node = node.nextSibling;
        continue start;
      }
      if (node == root)
        node = null;
      else
        node = node.parentNode;
    }
  }
}
------------------------------------------------------------------------

This code cannot be interpreted in a compliant implementation of
EcmaScript. It has more syntax errors than I can count. It is unclear
what the author thinks this code will do. If its intent were clearer,
and the syntax errors fewer, it might be possible for me to help out
by fixing them. The above code is not even close to ECMA262.

Examples should not contain errors.

Garrett



More information about the whatwg mailing list