Add an element to a list

@param  mixed  $element
@param  string $name
@return ListUnordered
199163
public function addElement($element, $name = null, $attrs = null) {
		switch (true) {
			case is_array($element):
				$newElement = new static($element);
				break;

			case $element instanceof self:
			case $element instanceof ListElement:
				$newElement = $element;
				break;

			default:
				$newElement = new ListElement($element, $attrs);
		}
		
		return parent::addElement($newElement, $name);
	}
267930
public function addElement(BasketElement $element)
    {
        $this->elements[] = $element;
        $element->setBasket($this);
        $element->setOrd(count($this->elements));

        return $this;
    }
951590
public function &addElement($element, $args = [])
    {
        $element = $this->factory->create($element, $args);

        $this->elementFactory('factory', $element);

        return $element;
    }
689747
public function addInputRange(string $name) : Element\Input\Range
    {
        $input = new Element\Input\Range($this, $name);
        $this->addComponent($name, $input);

        return $input;
    }
546161
public function addClass($name)
    {
        foreach ($this as $node) {
            if ($node instanceof \DOMElement) {
                /** @var \DOMElement $node */
                $classes = preg_split('/\s+/s', $node->getAttribute('class'));
                $found = false;
                $count = count($classes);
                for ($i = 0; $i < $count; $i++) {
                    if ($classes[$i] == $name) {
                        $found = true;
                    }
                }
                if (!$found) {
                    $classes[] = $name;
                    $node->setAttribute('class', trim(join(' ', $classes)));
                }
            }
        }
        return $this;
    }
244875
public function addElement(BaseElement $element): ContainerElement
    {
        $element->parent = $this;
        $this->children[] = $element;
        if ($element instanceof ContainerElement) {
            return $element;
        }

        return $this;
    }
888495
public function add($elements)
    {
        if (is_array($elements)) {
            foreach ($elements as $element) {
                $this->add($element);
            }
        } else {
            $this->collections->add($elements);
        }

        return $this;
    }
77149
protected function findByNameOrId($name, $element = '*')
    {
        $name = str_replace('#', '', $name);

        try {
            return $this->session->element('css selector', "#{$name}, *[name={$name}]");
        } catch (NoSuchElement $e) {
            throw new InvalidArgumentException(
                "Couldn't find an element, '{$element}', with a name or class attribute of '{$name}'."
            );
        }
    }
783744
public function appendChild(Element $element)
	{
		$this->beforeInsert($element);
		
		array_push($this->children, $element);
		
		$this->afterInsert();
		
		return $this;
	}
889167
public function addInputText(string $name) : Element\Input\Text
    {
        $input = new Element\Input\Text($this, $name);
        $this->addComponent($name, $input);

        return $input;
    }
1277179
public function setElement($name, $element, $position = null)
    {
        $name = trim($name);
        if ($name === '') {
            throw new InvalidArgumentException('Empty child name');
        } elseif (is_array($element)) {
            $config = $element;
            $config['parent'] = $this;
            $config['name'] = $name;
            $element = $this->createElement($config);
        } elseif (true === ($element instanceof \marvin255\serviform\interfaces\Field)) {
            $element->setName($name);
            $element->setParent($this);
        } else {
            throw new InvalidArgumentException('Wrong child type for field: ' . $name);
        }
        if ($position === null) {
            $this->elements[$name] = $element;
        } else {
            $elements = [];
            $itemPosition = $position < 0 ? count($this->elements) + $position : $position;
            $i = 0;
            foreach ($this->elements as $iKey => $iElement) {
                if ($i === $itemPosition) {
                    $elements[$name] = $element;
                }
                $elements[$iKey] = $iElement;
                ++$i;
            }
            $this->elements = $elements;
        }

        return $this;
    }
985701
public OrderBy add(String name, Order order) {
    failIfFieldNamePresent(name);
    this.elements.add(new SortElement(name, order, NullOrder.NULL_SMALLEST));
    return this;
  }
1028806
public function addInputButton(string $name) : Element\Input\Button
    {
        $input = new Element\Input\Button($this, $name);
        $this->addComponent($name, $input);

        return $input;
    }
1320875
static public function changeElementName(DOMElement $element, $name)
    {
        $newElement = $element->ownerDocument->createElement($name);

        foreach ($element->childNodes as $child) {
            $child = $element->ownerDocument->importNode($child, true);
            $newElement->appendChild($child);
        }

        foreach ($element->attributes as $attrName => $attrNode) {
            if ($attrNode->namespaceURI === null) {
                $newElement->setAttribute($attrName, $attrNode->value);
            } else {
                $newElement->setAttributeNS($attrNode->namespaceURI, $attrNode->prefix . ':' . $attrName, $attrNode->value);
            }

        }

        $newElement->ownerDocument->replaceChild($newElement, $element);

        return $newElement;
    }
438348
public function &getElementByName( $name )
	{
		$defaultResult = array();

		if ( ! property_exists( $this, 'elements_by_name' ) )
		{
			$this->elements_by_name = array();

			foreach ( $this->elementIndex as $elementsKey => &$element )
			{
				$this->elements_by_name[ $element['name'] ]  = &$element;
			}
		}

		if ( isset( $this->elements_by_name[ $name ] ) )
		{
			return $this->elements_by_name[ $name ];
		}
		return $defaultResult;

		return isset( $this->elements_by_name[ $name ] ) ? $this->elements_by_name[ $name ] : $defaultResult;
	}
99564
private function addElement($name, $parent = false, $ns = false)
    {
        if ($ns) {
            $el = $parent->ownerDocument->createElementNS($ns, $name);
        } else {
            $el = $parent->ownerDocument->createElement($name);
        }
        if ($parent) {
            $parent->appendChild($el);
        }

        return $el;
    }
303688
public function addElement(AbstractElement $element)
    {
        $name = $element->getName();
        if (in_array($name, $this->uniqueList)) {
            $this->elements[$name] = $element;
        } else {
            $this->elements[] = $element;
        }

        return $this;
    }