[whatwg] Update to the Adoption Agency Algorithm

Ian Hickson ian at hixie.ch
Fri Feb 3 23:38:23 PST 2006


On Sat, 4 Feb 2006, Bjoern Hoehrmann wrote:
>>
>> It's mathematically impossible to verify that all script on the page is 
>> always going to generate conformant DOMs, but indeed, a validator that 
>> attempts it should be given high marks.
> 
> Well, if you approach the problem by asking whether it's possible that 
> things become non-compliant, you'll either have to analyze any and all 
> dependencies like server-side scripts and workflows or you'd generate 
> false negatives, since adding some external data to the document is very 
> likely to generate errors if the external data is non-compliant. The 
> right approach here is to extend implementations to perform validation, 
> e.g. after each mutation event.

That still wouldn't work. Take this document:

   <!DOCTYPE HTML>
   <html>
    <head>
     <title> Test </title>
    </head>
    <body>
     <script>
      var N = 2;
      function tag() {
        if (Math.random() > 0.5)
          document.write('<div>');
        else
          document.write('<\/div>');
      }
      for (var i = 0; i < N; i += 1)
        tag();
     </script>
    </body>
   </html>

Is it conformant?

This is a simple case (it's conformant in 25% of cases; as you increase N 
it gets conformant in fewer and fewer cases -- how would your program test 
this?).

A more complex case would be something like:

   <!DOCTYPE HTML>
   <html>
    <head>
     <title> Test </title>
    </head>
    <body>
     <script>
      function test() {
        var isItTrue;
        /* something that tests whether
           Goldbach's conjecture is true
           or not and sets isItTrue to
           true or false as appropriate. */
        return isItTrue;
      }
      if (test())
        document.write('<div>');
      document.write('<\/div>');
     </script>
    </body>
   </html>

Is this document (with the comment replaced by appropriate code) 
conformant or not?

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'



More information about the whatwg mailing list