Skip to content

Setting DOMAttr::textContent results in an empty attribute value. #10234

Closed
ThePHPF/thephp.foundation
#90
@ThomasWeinert

Description

@ThomasWeinert

Description

The following code:

<?php
$document = new DOMDocument();
$document->loadXML('<element attribute="value"/>');
$attribute = $document->documentElement->getAttributeNode('attribute');

// output loaded attribute value
var_dump($attribute->textContent);

// change value
$attribute->textContent = 'new value';

// output changed value
var_dump($attribute->textContent);

Resulted in this output:

string(5) "value"
string(0) ""

But I expected this output instead:

string(5) "value"
string(9) "new value"

https://3v4l.org/ouRV0

This work in PHP Versions 5.6.1 to 5.6.13, it is broken for any PHP version after that.

PHP Version

PHP 8.2.1

Operating System

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions