parse attributes protected function parse_attr node name space Per sou

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// parse attributes
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.
$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
$atr_val = $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
$atr_val = $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;
$atr_val = $this->restore_noise($this->copy_until($this->token_attr));
}
// PaperG: Attributes should not have \r or \n in them, that counts as html whitespace.
$atr_val = str_replace("\r", "", $atr_val);
$atr_val = str_replace("\n", "", $atr_val);
// 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") {
$atr_val = trim($atr_val);
}
if (!isset($node->attr[$name]))
$node->attr[$name] = $atr_val;
}