From a4201427206817e212a06d33884f261b2c2eaea4 Mon Sep 17 00:00:00 2001 From: Simon Asika Date: Tue, 10 Dec 2024 16:23:05 +0800 Subject: [PATCH] build attributes --- packages/dom/src/DOMElement.php | 5 +++++ packages/dom/src/HTMLElement.php | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/dom/src/DOMElement.php b/packages/dom/src/DOMElement.php index 7cd0b2dca..de2cc1f22 100644 --- a/packages/dom/src/DOMElement.php +++ b/packages/dom/src/DOMElement.php @@ -407,8 +407,13 @@ public function createChild(string $name, array $attributes = [], $content = nul * * @return string */ + #[\Deprecated(message: 'Use HTMLElement::buildAttributes() instead.')] public static function buildAttributes(array|NativeDOMElement $attributes, ?string $type = null): string { + if ($type === null || $type === static::HTML) { + return HTMLElement::buildAttributes($attributes); + } + if ($attributes instanceof NativeDOMElement) { $attributes = array_map( fn(DOMAttr $attr) => $attr->value, diff --git a/packages/dom/src/HTMLElement.php b/packages/dom/src/HTMLElement.php index 0fe980847..7ae5191a3 100644 --- a/packages/dom/src/HTMLElement.php +++ b/packages/dom/src/HTMLElement.php @@ -120,13 +120,13 @@ public function render(bool $formatOutput = false): string throw new \LogicException('Please attach Element to a Document before render it.'); } - $formatOutputBak = $this->ownerDocument->formatOutput; - - $this->ownerDocument->formatOutput = $formatOutput; + // $formatOutputBak = $this->ownerDocument->formatOutput; + // + // $this->ownerDocument->formatOutput = $formatOutput; $result = HTML5Factory::saveHtml($this); - $this->ownerDocument->formatOutput = $formatOutputBak; + // $this->ownerDocument->formatOutput = $formatOutputBak; return $result; }