Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Tokenizer.php

function Tokenizer::attributeValue

Consume an attribute value. See section 8.2.4.37 and after.

Return value

string|null

1 call to Tokenizer::attributeValue()
Tokenizer::attribute in vendor/masterminds/html5/src/HTML5/Parser/Tokenizer.php
Parse attributes from inside of a tag.

File

vendor/masterminds/html5/src/HTML5/Parser/Tokenizer.php, line 522

Class

Tokenizer
The HTML5 tokenizer.

Namespace

Masterminds\HTML5\Parser

Code

protected function attributeValue() {
    if ('=' != $this->scanner
        ->current()) {
        return null;
    }
    $this->scanner
        ->consume();
    // 8.1.2.3
    $this->scanner
        ->whitespace();
    $tok = $this->scanner
        ->current();
    switch ($tok) {
        case "\n":
        case "\f":
        case ' ':
        case "\t":
            // Whitespace here indicates an empty value.
            return null;
        case '"':
        case "'":
            $this->scanner
                ->consume();
            return $this->quotedAttributeValue($tok);
        case '>':
            // case '/': // 8.2.4.37 seems to allow foo=/ as a valid attr.
            $this->parseError('Expected attribute value, got tag end.');
            return null;
        case '=':
        case '`':
            $this->parseError('Expecting quotes, got %s.', $tok);
            return $this->unquotedAttributeValue();
        default:
            return $this->unquotedAttributeValue();
    }
}
RSS feed
Powered by Drupal