summaryrefslogtreecommitdiff
path: root/src/HTML5
diff options
context:
space:
mode:
authorChristophe Coevoet <[email protected]>2018-11-24 18:35:02 +0100
committerChristophe Coevoet <[email protected]>2018-11-26 12:33:58 +0100
commit4c337c89096d9acb798f68201d2b124860d1616e (patch)
tree8b3d398f53324a2bc18ed78c3d3fe62de9e88238 /src/HTML5
parent7b339b5d8c364d62b0b982604f63085c91720702 (diff)
Simplify the doctype matching
- the doctype() function is only called for a D or d token, so there is no need to check again inside the method - checking that we have the DOCTYPE string can use a sequence matching
Diffstat (limited to 'src/HTML5')
-rw-r--r--src/HTML5/Parser/Tokenizer.php9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/HTML5/Parser/Tokenizer.php b/src/HTML5/Parser/Tokenizer.php
index 74d86a3..bba6ff2 100644
--- a/src/HTML5/Parser/Tokenizer.php
+++ b/src/HTML5/Parser/Tokenizer.php
@@ -721,12 +721,11 @@ class Tokenizer
*/
protected function doctype()
{
- if (strcasecmp($this->scanner->current(), 'D')) {
- return false;
- }
// Check that string is DOCTYPE.
- $chars = $this->scanner->charsWhile('DOCTYPEdoctype');
- if (strcasecmp($chars, 'DOCTYPE')) {
+ if ($this->scanner->sequenceMatches('DOCTYPE', false)) {
+ $this->scanner->consume(7);
+ } else {
+ $chars = $this->scanner->charsWhile('DOCTYPEdoctype');
$this->parseError('Expected DOCTYPE, got %s', $chars);
return $this->bogusComment('<!' . $chars);