PHP : Function Reference : DOM Functions : DOMElement->setIdAttribute()
elmarhinz
The second parameter doesn't exactly do, what you would expect. So use the method with care.
If it is TRUE the method works like a switch.
If it is FALSE the method turns ID setting off.
A unit test demonstrates the exact behaviour:
public function testSetIdAttribute() {
$this->assertNull($this->dom->getElementById('testChild'));
$this->child->setIdAttribute('id', TRUE);
$this->assertType('DOMElement', $this->dom->getElementById('testChild'));
$this->assertNotNull($this->dom->getElementById('testChild'));
// TRUE switches between on and off, while false turns it off.
$this->child->setIdAttribute('id', TRUE);
$this->assertNull($this->dom->getElementById('testChild'));
$this->child->setIdAttribute('id', TRUE);
$this->assertNotNull($this->dom->getElementById('testChild'));
$this->child->setIdAttribute('id', TRUE);
$this->assertNull($this->dom->getElementById('testChild'));
$this->child->setIdAttribute('id', TRUE);
$this->assertNotNull($this->dom->getElementById('testChild'));
// FALSE turns off and not on any more.
$this->child->setIdAttribute('id', FALSE);
$this->assertNull($this->dom->getElementById('testChild'));
$this->child->setIdAttribute('id', FALSE);
$this->assertNull($this->dom->getElementById('testChild'));
$this->child->setIdAttribute('id', FALSE);
$this->assertNull($this->dom->getElementById('testChild'));
}
|