EventHandler
interface EventHandler
Standard events for HTML5.
This is roughly analogous to a SAX2 or expat-style interface. However, it is tuned specifically for HTML5, according to section 8 of the HTML5 specification.
An event handler receives parser events. For a concrete implementation, see DOMTreeBuilder.
Quirks support in the parser is limited to close-in syntax (malformed tags or attributes). Higher order syntax and semantic issues with a document (e.g. mismatched tags, illegal nesting, etc.) are the responsibility of the event handler implementation.
See HTML5 spec section 8.2.4
Constants
DOCTYPE_NONE |
|
DOCTYPE_PUBLIC |
|
DOCTYPE_SYSTEM |
|
Methods
A doctype declaration.
A start tag.
An end-tag.
A comment section (unparsed character data).
A unit of parsed character data.
Indicates that the document has been entirely processed.
Emitted when the parser encounters an error condition.
A CDATA section.
This is a holdover from the XML spec.
Details
at line line 43
doctype(
string $name,
int $idType,
string $id = null,
boolean $quirks = false)
A doctype declaration.
at line line 74
int
startTag(
string $name,
array $attributes = array(),
boolean $selfClosing = false)
A start tag.
IMPORTANT: The parser watches the return value of this event. If this returns an integer, the parser will switch TEXTMODE patters according to the int.
This is how the Tree Builder can tell the Tokenizer when a certain tag should cause the parser to go into RAW text mode.
The HTML5 standard requires that the builder is the one that initiates this step, and this is the only way short of a circular reference that we can do that.
Example: if a startTag even for a script
name is fired, and the startTag()
implementation returns Tokenizer::TEXTMODE_RAW, then the tokenizer will
switch into RAW text mode and consume data until it reaches a closing
script
tag.
The textmode is automatically reset to Tokenizer::TEXTMODE_NORMAL when the closing tag is encounter. This behavior may change.
at line line 79
endTag($name)
An end-tag.
at line line 84
comment($cdata)
A comment section (unparsed character data).
at line line 91
text($cdata)
A unit of parsed character data.
Entities in this text are already decoded.
at line line 96
eof()
Indicates that the document has been entirely processed.
at line line 101
parseError($msg, $line, $col)
Emitted when the parser encounters an error condition.
at line line 109
cdata(
string $data)
A CDATA section.
at line line 121
processingInstruction(
string $name,
string $data = null)
This is a holdover from the XML spec.
While user agents don't get PIs, server-side does.