/** * All of the markup and content within a given element. */ public final void setInnerSafeHtml(SafeHtml html) { setInnerHTML(html.asString()); }
/** * Sets the HTML contained within an element. * * @param elem the element whose inner HTML is to be set * @param html the new html * @deprecated Use {@link Element#setInnerHTML(String)} instead. */ @Deprecated public static void setInnerHTML(Element elem, @IsSafeHtml String html) { elem.setInnerHTML(html); }
@Override public void setHTML(@IsSafeHtml String html) { setWidget(null); contentElem.setInnerHTML(html); }
@Override public final void setHTML(@IsSafeHtml String html) { if (beforeInitPlaceholder == null) { setHTMLImpl(html); } else { beforeInitPlaceholder.setInnerHTML(html); } }
private void setInnerTextOrHtml(@IsSafeHtml String content, boolean isHtml) { if (isHtml) { element.setInnerHTML(content); } else { element.setInnerText(content); } } }
/** * Creates a new, empty cell. */ @Override protected com.google.gwt.user.client.Element createCell() { Element td = super.createCell(); // Add a non-breaking space to the TD. This ensures that the cell is // displayed. td.setInnerHTML(" "); return DOM.asOld(td); }
/** * Replaces the contents of the specified cell with a single space. * * @param row the cell's row * @param column the cell's column * @throws IndexOutOfBoundsException */ @Override public boolean clearCell(int row, int column) { Element td = getCellFormatter().getElement(row, column); boolean b = internalClearCell(td, false); td.setInnerHTML(" "); return b; }
/** * Sets the HTML contents of the specified cell. * * @param row the cell's row * @param column the cell's column * @param html the cell's HTML contents * @throws IndexOutOfBoundsException */ public void setHTML(int row, int column, @IsSafeHtml String html) { prepareCell(row, column); Element td = cleanCell(row, column, html == null); if (html != null) { td.setInnerHTML(html); } }
public static Element fromHtml(@IsSafeHtml String html) { ensureHiddenDiv(); hiddenDiv.setInnerHTML(html); Element newbie = hiddenDiv.getFirstChildElement(); orphan(newbie); return newbie; }
/** * Set the face's contents as html. * * @param html html to set as face's contents html * */ @Override public void setHTML(@IsSafeHtml String html) { face = DOM.createDiv(); UIObject.setStyleName(face, STYLENAME_HTML_FACE, true); face.setInnerHTML(html); updateButtonFace(); }
@Override @SuppressIsSafeHtmlCastCheck public Element createElement(Document doc, String tagName) { if (tagName.contains(":")) { // Special implementation for tag names with namespace-prefixes. The only // way to get IE to reliably create namespace-prefixed elements is // through innerHTML. Element container = ensureContainer(doc); container.setInnerHTML("<" + tagName + "/>"); // Remove the element before returning it, so that there's no chance of // it getting clobbered later. Element elem = container.getFirstChildElement(); container.removeChild(elem); return elem; } // No prefix. Just use the default implementation (don't use super impl // here in case it changes at some point in the future). return createElementInternal(doc, tagName); }
outerElem.setInnerHTML("<div></div>");
public void setCaption( FieldSetElement fieldset, Element legend, @IsSafeHtml String caption, boolean asHTML) { // TODO(bruce): rewrite to be inlinable assert (caption != null); if (asHTML) { legend.setInnerHTML(caption); } else { legend.setInnerText(caption); } if (!"".equals(caption)) { // This is formulated to become an append (if there's no widget), an // insertion at index 0 (if there is a widget but no legend already), or // a no-op (if the legend is already in place). fieldset.insertBefore(legend, fieldset.getFirstChild()); } else if (legend.getParentNode() != null) { // We remove the legend from the DOM because leaving it in with an empty // string renders as an ugly gap in the top border on some browsers. fieldset.removeChild(legend); } } }
/** * Sets the element's content to the given value (either plain text or HTML), * applying the given direction. Prefer using * {@link #setText(String, com.google.gwt.i18n.client.HasDirection.Direction) setText} or * {@link #setHtml(String, com.google.gwt.i18n.client.HasDirection.Direction) setHtml} * instead of this method. * * @param content the element's new content * @param dir the content's direction * @param isHtml whether the content is HTML */ public void setTextOrHtml(@IsSafeHtml String content, Direction dir, boolean isHtml) { textDir = dir; // Set the text and the direction. if (isElementInline) { isSpanWrapped = true; element.setInnerHTML(BidiFormatter.getInstanceForCurrentLocale( true /* alwaysSpan */).spanWrapWithKnownDir(dir, content, isHtml)); } else { isSpanWrapped = false; BidiUtils.setDirectionOnElement(element, dir); setInnerTextOrHtml(content, isHtml); } isDirectionExplicitlySet = true; }
/** * Put the node back into a clean state and clear fields. */ private void cleanup() { if (opening) { animFrame.getStyle().clearDisplay(); } else { animFrame.getStyle().setDisplay(Display.NONE); childContainer.setInnerHTML(""); } animFrame.getStyle().clearHeight(); animFrame.getStyle().clearPosition(); this.contentContainer = null; this.childContainer = null; this.animFrame = null; } }
@Override @SuppressIsSafeHtmlCastCheck public void uninitElement() { isReady = false; // Issue 1897: initElement uses a timeout, so its possible to call this // method after calling initElement, but before the event system is in // place. if (initializing) { initializing = false; return; } // Unhook all custom event handlers when the element is detached. unhookEvents(); // Recreate the placeholder element and store the iframe's contents and the // enabled status in it. This is necessary because some browsers will wipe // the iframe's contents when it is removed from the DOM. @IsSafeHtml String html = getHTML(); // TODO: mXSS boolean enabled = isEnabled(); beforeInitPlaceholder = DOM.createDiv(); beforeInitPlaceholder.setInnerHTML(html); setEnabled(enabled); }
/** * Sets the text associated with a child by its index. * * @param index the index of the child whose text is to be set * @param text the text to be associated with it * @param asHTML <code>true</code> to treat the specified text as HTML */ public void setStackText(int index, @IsSafeHtml String text, boolean asHTML) { if (index >= getWidgetCount()) { return; } Element tdWrapper = DOM.getChild(DOM.getChild(body, index * 2), 0); Element headerElem = DOM.getFirstChild(tdWrapper); if (asHTML) { getHeaderTextElem(headerElem).setInnerHTML(text); } else { getHeaderTextElem(headerElem).setInnerText(text); } }
contentElem.setInnerHTML("");
@Override public void init(final TreeHierarchyInternalItemPresenter presenter) { this.presenter = presenter; final String preferenceLabel = getPreferenceLabel(presenter.getHierarchyElement().getBundleKey()); label.setInnerHTML(preferenceLabel); treeNode.getStyle().setProperty("padding-left", presenter.getLevel() * 27 + 8 + "px"); presenter.getHierarchyItems().forEach(hierarchyItem -> { children.appendChild(((IsElement) hierarchyItem.getView()).getElement()); }); }
public void testToastWithStyling() { MaterialToast.fireToast("test", "rounded"); Element toastContainer = $("body").find("#toast-container").asElement(); assertNotNull(toastContainer); assertEquals(toastContainer.getChildCount(), 1); assertNotNull(toastContainer.getChild(0)); assertTrue(toastContainer.getChild(0) instanceof Element); Element toastElement = (Element) toastContainer.getChild(0); assertTrue(toastElement.hasClassName("rounded")); toastContainer.setInnerHTML(""); }