note 75257 deleted from domdocument.setidattribute by danbrown

From: Date: Fri, 28 Nov 2008 22:56:57 +0000
Subject: note 75257 deleted from domdocument.setidattribute by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-147397@lists.php.net to get a copy of this message
Note Submitter: 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')); }

« previous php.notes (#147397) next »