/[suikacvs]/markup/html/scripting-parser/parser.html
Suika

Diff of /markup/html/scripting-parser/parser.html

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.14 by wakaba, Tue Apr 29 02:50:00 2008 UTC revision 1.15 by wakaba, Tue Apr 29 03:29:41 2008 UTC
# Line 65  Line 65 
65    
66    var logIndentLevel = 0;    var logIndentLevel = 0;
67    function log (s) {    function log (s) {
68        var indent = '';
69      for (var i = 0; i < logIndentLevel; i++) {      for (var i = 0; i < logIndentLevel; i++) {
70        s = '  ' + s;        indent += '  ';
71      }      }
72        s = indent + s.replace (/\n/g, "\n" + indent);
73      document.logElement.appendChild (document.createTextNode (s + "\n"));      document.logElement.appendChild (document.createTextNode (s + "\n"));
74    } // log    } // log
75    
# Line 501  Line 503 
503        // 2.4. If the script element has its "already executed" flag set        // 2.4. If the script element has its "already executed" flag set
504        if (e.manakaiAlreadyExecuted) {        if (e.manakaiAlreadyExecuted) {
505          // 2.5. Abort these steps at this point.          // 2.5. Abort these steps at this point.
506          log ('Running a script: aborted');          log ('Running a script: aborted (already executed)');
507          logIndentLevel--;          logIndentLevel--;
508          return e;          return e;
509        }        }
# Line 612  Line 614 
614          doc.write.apply (doc, args);          doc.write.apply (doc, args);
615          return '';          return '';
616        });        });
617        s = s.replace (/^\s*var\s+s\s*=\s*document\.createElement\s*\(\s*['"]script['"]\s*\)\s*;\s*s\.src\s*=\s*(?:'(javascript:[^']*)'|"(javascript:[^"]*)")\s*;\s*document\.documentElement\.appendChild\s*\(\s*s\s*\)\s*;\s*/,        var noDocumentElement = false;
618          s = s.replace (/^\s*var\s+s\s*=\s*document\.createElement\s*\(\s*['"]script['"]\s*\)\s*;\s*s\.src\s*=\s*(?:'([^']*)'|"([^"]*)")\s*;\s*document\.documentElement\.appendChild\s*\(\s*s\s*\)\s*;\s*/,
619        function (s, t, u) {        function (s, t, u) {
620          matched = true;          matched = true;
621          var args = [unescapeJSLiteral (t ? t : u)];          var args = [unescapeJSLiteral (t ? t : u)];
622          doc._insertExternalScript.apply (doc, args);          noDocumentElement = !doc._insertExternalScript.apply (doc, args);
623            return '';
624          });
625          if (noDocumentElement) {
626            log ('Script error: documentElement is null');
627            break;
628          }
629          s = s.replace (/^\s*w\s*\(\s*document\.documentElement\.innerHTML\s*\)\s*;\s*/,
630          function (s, t) {
631            matched = true;
632            log (dumpTree (doc, ''));
633          return '';          return '';
634        });        });
635        if (s == '') break;        if (s == '') break;
# Line 701  Line 714 
714    }; // document.open    }; // document.open
715    
716    JSDocument.prototype.write = function () {    JSDocument.prototype.write = function () {
717        log ('document.write: start');
718      logIndentLevel++;      logIndentLevel++;
719    
720      var p = this._parser;      var p = this._parser;
# Line 724  Line 738 
738      if (p.scriptExecutedAfterParserResumes) {      if (p.scriptExecutedAfterParserResumes) {
739        log ('document.write: processed later (there is an unprocessed <script src>)');        log ('document.write: processed later (there is an unprocessed <script src>)');
740        logIndentLevel--;        logIndentLevel--;
741          log ('document.write: return');
742        return;        return;
743      }      }
744    
# Line 737  Line 752 
752      // to do something here?      // to do something here?
753    
754      // 5. Return      // 5. Return
755        logIndentLevel--;
756      log ('document.write: return');      log ('document.write: return');
757    
     logIndentLevel--;  
758      return;      return;
759    }; // document.write    }; // document.write
760    
761    JSDocument.prototype._insertExternalScript = function (uri) {    JSDocument.prototype._insertExternalScript = function (uri) {
762      var s = new JSElement (this, 'script');      var s = new JSElement (this, 'script');
763      s.src = uri;      s.src = uri;
764      this.documentElement.appendChild (s);      if (this.documentElement) {
765          this.documentElement.appendChild (s);
766          return true;
767        } else {
768          return false;
769        }
770    }; // _insertExternalScript    }; // _insertExternalScript
771    
772    JSDocument.prototype.__defineGetter__ ('documentElement', function () {    JSDocument.prototype.__defineGetter__ ('documentElement', function () {
# Line 863  introduced, followed, or separated by wh Line 883  introduced, followed, or separated by wh
883    <li><code>var s = document.createElement ("script");    <li><code>var s = document.createElement ("script");
884              s.src = "<var>string</var>";              s.src = "<var>string</var>";
885              document.documentElement.appendChild (s);</code>              document.documentElement.appendChild (s);</code>
886      <li><code>w (document.documentElement.innerHTML);</code> (This statement
887      can be used to dump the document, even when the document has no
888      document element.  The output format is the tree dump format used
889      in html5lib test data, not <abbr>HTML</abbr>.)
890    </ul>    </ul>
891  Note that strings may be delimited by <code>'</code>s instead of  Note that strings may be delimited by <code>'</code>s instead of
892  <code>"</code>s.  <code>"</code>s.

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.15

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24