public function OutputRules::element in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/masterminds/html5/src/HTML5/Serializer/OutputRules.php \Masterminds\HTML5\Serializer\OutputRules::element()
Write an element.
Instead of returning the result write it to the output stream ($output) that was passed into the constructor.
Parameters
mixed $ele:
Overrides RulesInterface::element
File
- vendor/
masterminds/ html5/ src/ HTML5/ Serializer/ OutputRules.php, line 199 - The rules for generating output in the serializer.
Class
- OutputRules
- Generate the output html5 based on element rules.
Namespace
Masterminds\HTML5\SerializerCode
public function element($ele) {
$name = $ele->tagName;
// Per spec:
// If the element has a declared namespace in the HTML, MathML or
// SVG namespaces, we use the lname instead of the tagName.
if ($this->traverser
->isLocalElement($ele)) {
$name = $ele->localName;
}
// If we are in SVG or MathML there is special handling.
// Using if/elseif instead of switch because it's faster in PHP.
if ($name == 'svg') {
$this->outputMode = static::IM_IN_SVG;
$name = Elements::normalizeSvgElement($name);
}
elseif ($name == 'math') {
$this->outputMode = static::IM_IN_MATHML;
}
$this
->openTag($ele);
if (Elements::isA($name, Elements::TEXT_RAW)) {
foreach ($ele->childNodes as $child) {
$this
->wr($child->data);
}
}
else {
// Handle children.
if ($ele
->hasChildNodes()) {
$this->traverser
->children($ele->childNodes);
}
// Close out the SVG or MathML special handling.
if ($name == 'svg' || $name == 'math') {
$this->outputMode = static::IM_IN_HTML;
}
}
// If not unary, add a closing tag.
if (!Elements::isA($name, Elements::VOID_TAG)) {
$this
->closeTag($ele);
}
}