@description
Clone an element of the DOM.

@param elem DOM element to clone or ID of such an element.
@param id ID to give to the new element.
All its children that own an ID will get it prefixed with the ID of the new element.
@memberof dom.Util
193529
function(elem, id) {
            if (typeof elem === 'string') {
                elem = document.getElementById(elem);
                if (!elem) return null;
            }
            var copy = elem.cloneNode(true);
            if (typeof id === 'string') {
                var i, div, divs, prefix = id + ".";
                divs = copy.querySelectorAll("[id]");
                for (i = 0 ; i < divs.length ; i++) {
                    div = divs[i];
                    div.setAttribute("id", prefix + div.getAttribute("id"));
                }
                delete copy.style.display;
                copy.removeAttribute("style");
                copy.setAttribute("id", id);
            }
            return copy;
        }
426249
protected Button newButton(final String id)
	{
		return new Button(id)
		{
			/** The serialVersionUID. */
			private static final long serialVersionUID = 1L;

			@Override
			public void onSubmit()
			{
				onSignup(ComponentFinder.findOrCreateNewAjaxRequestTarget(), getForm());
			}
		};
	}
1214119
public void createAndEditNewElement(
        final org.opencms.ade.containerpage.client.ui.CmsContainerPageElementPanel element,
        final CmsUUID modelResourceStructureId) {

        CmsRpcAction<CmsContainerElement> action = new CmsRpcAction<CmsContainerElement>() {

            @Override
            public void execute() {

                getContainerpageService().createNewElement(
                    CmsCoreProvider.get().getStructureId(),
                    element.getId(),
                    element.getNewType(),
                    modelResourceStructureId,
                    getLocale(),
                    this);

            }

            @Override
            protected void onResponse(CmsContainerElement result) {

                openEditorForNewElement(element, result, false);

            }
        };
        action.execute();
    }
1206081
protected CmsDirectEditButtons processEditableElement(Element elem) {

        RootPanel root = RootPanel.get();
        CmsDirectEditButtons result = new CmsDirectEditButtons(elem, null);
        root.add(result);
        result.setPosition(m_positions.get(elem.getId()), m_buttonPositions.get(elem.getId()), elem.getParentElement());
        return result;
    }
725887
public Document cloneDocument(DOMImplementation domImpl, Document document) {
    Element root = document.getDocumentElement();
    // New document
    Document result = domImpl.createDocument(root.getNamespaceURI(), root.getNodeName(), null);
    Element rroot = result.getDocumentElement();
    // Cloning the document element is a bit tricky.
    // This is adopted from DomUtilities#deepCloneDocument
    boolean before = true;
    for(Node n = document.getFirstChild(); n != null; n = n.getNextSibling()) {
      if(n == root) {
        before = false;
        copyAttributes(result, root, rroot);
        for(Node c = root.getFirstChild(); c != null; c = c.getNextSibling()) {
          final Node cl = cloneNode(result, c);
          if(cl != null) {
            rroot.appendChild(cl);
          }
        }
      }
      else {
        if(n.getNodeType() != Node.DOCUMENT_TYPE_NODE) {
          final Node cl = cloneNode(result, n);
          if(cl != null) {
            if(before) {
              result.insertBefore(cl, rroot);
            }
            else {
              result.appendChild(cl);
            }
          }
        }
      }
    }
    return result;
  }
297987
function(elem, child) {
		if (child) {
			if (elem.nodeType === 8) { // comment
				if (child.nodeType === 3) { // text node
					elem.nodeValue += child.nodeValue;
				}

			} else if (elem.canHaveChildren !== false) {
				elem.appendChild(child);
			}
		}
	}
1035368
function (id, type, elem) {
            var self = this;
            $.each(elem.options.eventHandlers, function (event) {
                if (self.customEventHandlers[event] === undefined) self.customEventHandlers[event] = {};
                if (self.customEventHandlers[event][type] === undefined) self.customEventHandlers[event][type] = {};
                self.customEventHandlers[event][type][id] = elem;
            });
        }
493804
void copyIdField(Element readNode) {
        String newId = readNode.getAttribute("data-semantic-id");
        if (!StringUtils.isEmpty(newId)) {
            readNode.setAttribute("id", "p" + newId);
        }
        for (Node child : new NonWhitespaceNodeList(readNode.getChildNodes())) {
            if (child instanceof Element) {
                copyIdField((Element) child);
            }
        }
    }
134766
function (id) {
    /* Get the corresponding html element. */
    var domelt = document.querySelector(id);
    if (!domelt) {
      return { on: function () {} };
    }

    /* Now that we have the elt and onprop, assign it. */
    domelt.on = onprop;
    return domelt;
  }
1194949
public static void replaceResourceIds(Element element, String oldId, String newId) {

        NodeList<Element> children = CmsDomUtil.querySelectorAll(
            FIELD_SELECTOR + ENTITY_ID_SELECTOR_PREFIX + oldId + ENTITY_ID_SELECTOR_SUFFIX,
            element);
        if (children.getLength() > 0) {
            for (int i = 0; i < children.getLength(); i++) {
                Element child = children.getItem(i);
                String idData = child.getAttribute(CmsGwtConstants.ATTR_DATA_ID);
                idData = idData.replace(oldId, newId);
                child.setAttribute(CmsGwtConstants.ATTR_DATA_ID, idData);
            }
        }
    }
1146684
public void deleteElement(String elementId, final String relatedElementId) {

        elementId = getServerId(elementId);
        removeContainerElements(elementId);
        addToRecentList(elementId, null);
        reloadElements(new String[] {relatedElementId});
    }
614086
public final synchronized void removeId(long id)
	{
		if (tc.isEntryEnabled()) Tr.entry(tc, "removeId", new Long(id));

		_idMap.remove(id);

		if (tc.isEntryEnabled()) Tr.exit(tc, "removeId");
	}
145375
function (el, newParent) {
			var _dom = this.getElement(el),
				_id = this.getId(_dom),
				_pdom = this.getElement(newParent),
				_pid = this.getId(_pdom);

			_dom.parentNode.removeChild(_dom);
			_pdom.appendChild(_dom);
			this.getDragManager().setParent(_dom, _id, _pdom, _pid);
		}
871979
protected Button newButton(final String id)
	{
		return new Button(id)
		{
			/** The serialVersionUID. */
			private static final long serialVersionUID = 1L;

			/**
			 * {@inheritDoc}
			 */
			@Override
			public void onSubmit()
			{
				onDeregistration(null);
			}
		};
	}
1125452
@Override
    public void add(int index, Object element) {
        rewrite |= index < delegate.size();

        delegate.add(index, element);
    }
935951
static Element appendChild(Element plfChild, Element parent, boolean copyChildren) {
        Document document = parent.getOwnerDocument();
        Element copy = (Element) document.importNode(plfChild, false);
        parent.appendChild(copy);

        // set the identifier for the doc if warrented
        String id = copy.getAttribute(Constants.ATT_ID);
        if (id != null && !id.equals("")) copy.setIdAttribute(Constants.ATT_ID, true);

        if (copyChildren) {
            NodeList children = plfChild.getChildNodes();
            for (int i = 0; i < children.getLength(); i++) {
                if (children.item(i) instanceof Element)
                    appendChild((Element) children.item(i), copy, true);
            }
        }
        return copy;
    }
397032
public boolean removeChild(String id) {
        SharedPreferences prefs = loadSharedPreferences("children");

        List<String> objects = getChildrenList();

        if (objects.indexOf(id) == ArrayUtils.INDEX_NOT_FOUND) {
            return false;
        }

        objects.remove(id);
        prefs.edit().putString(String.valueOf(getId()), StringUtils.join(objects, ",")).commit();

        return true;
    }