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

Breadcrumb

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

function Parser::parseJSXChild

Parses a jsx child

Return value

\Peast\Syntax\Node\Node|null

1 call to Parser::parseJSXChild()
Parser::parseJSXChildren in vendor/mck89/peast/lib/Peast/Syntax/JSX/Parser.php
Parses a group of jsx children

File

vendor/mck89/peast/lib/Peast/Syntax/JSX/Parser.php, line 110

Class

Parser
JSX parser trait

Namespace

Peast\Syntax\JSX

Code

protected function parseJSXChild() {
    if ($node = $this->parseJSXText()) {
        return $node;
    }
    elseif ($node = $this->parseJSXFragment()) {
        return $node;
    }
    elseif ($node = $this->parseJSXElement()) {
        return $node;
    }
    elseif ($startToken = $this->scanner
        ->consume("{")) {
        $spread = $this->scanner
            ->consume("...");
        $exp = $this->parseAssignmentExpression();
        $midPos = $this->scanner
            ->getPosition();
        if ($spread && !$exp || !$this->scanner
            ->consume("}")) {
            $this->error();
        }
        $node = $this->createJSXNode($spread ? "JSXSpreadChild" : "JSXExpressionContainer", $startToken);
        if (!$exp) {
            $exp = $this->createJSXNode("JSXEmptyExpression", $midPos);
            $this->completeNode($exp, $midPos);
        }
        $node->setExpression($exp);
        return $this->completeNode($node);
    }
    return null;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal