public function startTag($tag, $attr) { $attr = array_reverse($attr, true); // funny bit $tag = strtolower($tag); $element = new PHPricot_Nodes_Element($tag, $attr, $this->currentContexts); $element->parent = $this->currentParent; $this->currentParent->childNodes[] = $element; if (!$element->isSelfClosing()) { $this->currentParent = $element; array_push($this->stack, $element); } if (isset($attr['id'])) { $this->document->idElements[$attr['id']][] = $element; } if (isset($attr['class'])) { foreach (explode(" ", $attr['class']) as $class) { $this->document->classElements[$class][] = $element; } } }
public function testMatchingHasAttribute() { $tag = new PHPricot_Nodes_Element('p', array('foo' => 'bar')); $this->assertEquals('bar', $tag->attr('foo')); $this->assertTrue($tag->matching(null, null, null, array('foo' => null))); }