protected function parse_attr($node, $name, &$space)
{
// Per sourceforge: http://sourceforge.net/tracker/?func=detail&aid=3061408&group_id=218559&atid=1044037
// If the attribute is already defined inside a tag, only pay atetntion to the first one as opposed to the last one.
if (isset($node->attr[$name])) {
return;
}
$space[2] = $this->copy_skip($this->token_blank);
switch ($this->char) {
case '"':
$node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_DOUBLE;
$this->char = ++$this->pos < $this->size ? $this->doc[$this->pos] : null;
// next
$node->attr[$name] = $this->restore_noise($this->copy_until_char_escape('"'));
$this->char = ++$this->pos < $this->size ? $this->doc[$this->pos] : null;
// next
break;
case '\'':
$node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_SINGLE;
$this->char = ++$this->pos < $this->size ? $this->doc[$this->pos] : null;
// next
$node->attr[$name] = $this->restore_noise($this->copy_until_char_escape('\''));
$this->char = ++$this->pos < $this->size ? $this->doc[$this->pos] : null;
// next
break;
default:
$node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_NO;
$node->attr[$name] = $this->restore_noise($this->copy_until($this->token_attr));
}
// PaperG: Attributes should not have \r or \n in them, that counts as html whitespace.
$node->attr[$name] = str_replace("\r", "", $node->attr[$name]);
$node->attr[$name] = str_replace("\n", "", $node->attr[$name]);
// PaperG: If this is a "class" selector, lets get rid of the preceeding and trailing space since some people leave it in the multi class case.
if ($name == "class") {
$node->attr[$name] = trim($node->attr[$name]);
}
}