295 |
// 8.1. If the parser were originally created for the ... |
// 8.1. If the parser were originally created for the ... |
296 |
if (this.fragmentParsingMode) { |
if (this.fragmentParsingMode) { |
297 |
// 8.2. Mark the script element as "already executed" and ... |
// 8.2. Mark the script element as "already executed" and ... |
298 |
el.alreadyExecuted = true; |
el.manakaiAlreadyExecuted = true; |
299 |
continue; |
continue; |
300 |
} |
} |
301 |
|
|
521 |
var doc = this.ownerDocument || this; |
var doc = this.ownerDocument || this; |
522 |
var p = doc._parser; |
var p = doc._parser; |
523 |
|
|
524 |
// 1. Script type |
// 1.The script's type |
525 |
// |
// |
526 |
|
|
527 |
// 2.1. If scripting is disabled |
// 2. The cript's character encoding |
528 |
|
// |
529 |
|
|
530 |
|
// 3.1. If without script |
531 |
// |
// |
532 |
// 2.2. If the script element was created by an XML ... innerHTML ... |
// 2.2. If the script element was created by an XML ... innerHTML ... |
533 |
// |
// |
534 |
// 2.3. If the user agent does not support the scripting language ... |
// 2.3. If the user agent does not support the scripting language ... |
535 |
// |
// |
536 |
// 2.4. If the script element has its "already executed" flag set |
if (false) { |
|
if (e.manakaiAlreadyExecuted) { |
|
537 |
// 2.5. Abort these steps at this point. |
// 2.5. Abort these steps at this point. |
538 |
log ('Running a script: aborted (already executed)'); |
log ('Running a script: aborted (noscript)'); |
539 |
logIndentLevel--; |
logIndentLevel--; |
540 |
return e; |
return e; |
541 |
} |
} |
542 |
|
|
543 |
// 3. Set the element's "already executed" flag. |
// 4. Set the element's "already executed" flag. |
544 |
e.manakaiAlreadyExecuted = true; |
e.manakaiAlreadyExecuted = true; |
545 |
|
|
546 |
// 4. If the element has a src attribute, then a load for ... |
// 5. If the element has a src attribute, then a load for ... |
547 |
// TODO: load an external resource |
// TODO: load an external resource |
548 |
|
|
549 |
// 5. The first of the following options: |
// 5. The first of the following options: |
550 |
|
|
|
// 5.1. |
|
551 |
if (/* TODO: If the document is still being parsed && */ |
if (/* TODO: If the document is still being parsed && */ |
552 |
e.defer && !e.async) { |
e.defer && !e.async) { |
553 |
|
// 6.1. |
554 |
p.scriptsExecutedAfterParsing.push (e); |
p.scriptsExecutedAfterParsing.push (e); |
555 |
log ('Running a script: aborted (defer)'); |
log ('Running a script: aborted (defer)'); |
556 |
} else if (e.async && e.src != null) { |
} else if (e.async && e.src != null) { |
557 |
|
// 6.2. |
558 |
p.scriptsExecutedAsynchronously.push (e); |
p.scriptsExecutedAsynchronously.push (e); |
559 |
log ('Running a script: aborted (async src)'); |
log ('Running a script: aborted (async src)'); |
560 |
} else if (e.async && e.src == null && |
} else if (e.async && e.src == null && |
561 |
p.scriptsExecutedAsynchronously.length > 0) { |
p.scriptsExecutedAsynchronously.length > 0) { |
562 |
|
// 6.3. |
563 |
p.scriptsExecutedAsynchronously.push (e); |
p.scriptsExecutedAsynchronously.push (e); |
564 |
log ('Running a script: aborted (async)'); |
log ('Running a script: aborted (async)'); |
|
// ISSUE: What is the difference with the case above? |
|
565 |
} else if (e.src != null && e.manakaiParserInserted) { |
} else if (e.src != null && e.manakaiParserInserted) { |
566 |
|
// 6.4. |
567 |
if (p.pendingExternalScript) { |
if (p.pendingExternalScript) { |
568 |
log ('Error: There is a pending external script.'); |
log ('Error: There is a pending external script.'); |
569 |
} |
} |
570 |
p.pendingExternalScript = e; |
p.pendingExternalScript = e; |
571 |
log ('Running a script: aborted (src parser-inserted)'); |
log ('Running a script: aborted (src parser-inserted)'); |
572 |
} else if (e.src != null) { |
} else if (e.src != null) { |
573 |
|
// 6.5. |
574 |
p.scriptsExecutedSoon.push (e); |
p.scriptsExecutedSoon.push (e); |
575 |
log ('Running a script: aborted (src)'); |
log ('Running a script: aborted (src)'); |
576 |
} else { |
} else { |
577 |
|
// 6.6. |
578 |
executeScript (doc, e); // even if other scripts are already executing. |
executeScript (doc, e); // even if other scripts are already executing. |
579 |
} |
} |
580 |
|
|
890 |
|
|
891 |
<h2 id=notes>Notes</h2> |
<h2 id=notes>Notes</h2> |
892 |
|
|
893 |
<p>This is a <em>simplified</em> implementation of |
<p>This is a <em>simplified</em> implementation of <a |
894 |
<a href="http://www.whatwg.org/specs/web-apps/current-work/#parsing">HTML5 |
href="http://www.whatwg.org/specs/web-apps/current-work/#parsing">HTML5 |
895 |
Parsing Algorithm</a>. It only implements script-related part of the |
Parsing Algorithm</a> (revision 2138). It only implements |
896 |
algorithm. Especially, this parser: |
scripting-related parts of the algorithm. Especially, this parser: |
897 |
|
|
898 |
<ul> |
<ul> |
899 |
<li>Does not support <code>DOCTYPE</code> and comment tokens. |
<li>Does not support <code>DOCTYPE</code> and comment tokens. |
900 |
<li>Does not support entities except for <code>&quot;</code>, |
<li>Does not support entities except for <code>&quot;</code>, |