/** * Add an array of attributes to the tag. * * Merges class and style attributes * Accepts attributes in string format. * * @param mixed $attrs the new attributes. * * @return void */ public function setAttrs($attrs) { $oldAttrs = $this->attributes; $oldClasses = $this->classes; $this->attributes = $attrs; $this->attributes = Generator::parseAtts($this); $this->attributes = array_merge($oldAttrs, $this->attributes); $this->classes = null; $this->update('classes'); if (!empty($oldClasses) && !empty($this->classes)) { $this->attributes['class'] = implode(' ', array_merge($oldClasses, $this->classes)); } $this->classes = null; if (!empty($oldAttrs['style']) && !empty($this->attributes['style'])) { $this->attributes['style'] = Generator::mergeStyles($this->attributes['style'], $oldAttrs['style']); } $this->update(); }