com.vaadin.flow.dom.Element.removeAttribute()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(9.9k)|赞(0)|评价(0)|浏览(147)

本文整理了Java中com.vaadin.flow.dom.Element.removeAttribute()方法的一些代码示例,展示了Element.removeAttribute()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.removeAttribute()方法的具体详情如下:
包路径:com.vaadin.flow.dom.Element
类名称:Element
方法名:removeAttribute

Element.removeAttribute介绍

[英]Removes the given attribute.

Attribute names are considered case insensitive and all names will be converted to lower case automatically.

If the attribute has not been set, does nothing.

Note that attribute changes made on the server are sent to the client but attribute changes made on the client side are not reflected back to the server.
[中]删除给定的属性。
属性名称不区分大小写,所有名称将自动转换为小写。
如果尚未设置属性,则不执行任何操作。
请注意,在服务器上所做的属性更改会发送到客户端,但在客户端所做的属性更改不会反映回服务器。

代码示例

代码示例来源:origin: com.vaadin/flow-server

private void updateThemeAttribute() {
  if (themes.isEmpty()) {
    element.removeAttribute(THEME_ATTRIBUTE_NAME);
  } else {
    element.setAttribute(THEME_ATTRIBUTE_NAME, themes.stream()
        .collect(Collectors.joining(THEME_NAMES_DELIMITER)));
  }
}

代码示例来源:origin: com.vaadin/vaadin-upload-flow

/**
 * Set the receiver implementation that should be used for this upload
 * component.
 * <p>
 * Note! If the receiver doesn't implement {@link MultiFileReceiver} then
 * the upload will be automatically set to only accept one file.
 *
 * @param receiver
 *            receiver to use for file reception
 */
public void setReceiver(Receiver receiver) {
  this.receiver = receiver;
  if (!(receiver instanceof MultiFileReceiver)) {
    setMaxFiles(1);
  } else {
    getElement().removeAttribute("maxFiles");
  }
}

代码示例来源:origin: com.vaadin/vaadin-form-layout-flow

/**
   * Removes all contents from this component, this includes child components,
   * text content as well as child elements that have been added directly to
   * this component using the {@link Element} API.
   */
  protected void removeAll() {
    getElement().getChildren()
        .forEach(child -> child.removeAttribute("slot"));
    getElement().removeAllChildren();
  }
}

代码示例来源:origin: com.vaadin/flow-component-demo-helpers

/**
 * Sets an specific anchor as active. The previous active anchor, if
 * existent, is made inactive.
 *
 * @param href
 *            the href of the anchor to be set as active, or
 *            <code>null</code> to inactivate all the anchors.
 */
public void setActive(String href) {
  if (active != null) {
    active.getElement().removeAttribute("active");
  }
  active = anchors.get(href);
  if (active != null) {
    active.getElement().setAttribute("active", true);
  }
}

代码示例来源:origin: com.vaadin/vaadin-text-field-flow

/**
 * Removes all contents from this component, this includes child components,
 * text content as well as child elements that have been added directly to
 * this component using the {@link Element} API.
 */
protected void removeAll() {
  getElement().getChildren()
      .forEach(child -> child.removeAttribute("slot"));
  getElement().removeAllChildren();
}

代码示例来源:origin: com.vaadin/vaadin-split-layout-flow

/**
   * Removes all contents from this component, this includes child components,
   * text content as well as child elements that have been added directly to
   * this component using the {@link Element} API.
   */
  protected void removeAll() {
    getElement().getChildren()
        .forEach(child -> child.removeAttribute("slot"));
    getElement().removeAllChildren();
  }
}

代码示例来源:origin: com.vaadin/vaadin-upload-flow

/**
   * Removes all contents from this component, this includes child components,
   * text content as well as child elements that have been added directly to
   * this component using the {@link Element} API.
   */
  protected void removeAll() {
    getElement().getChildren()
        .forEach(child -> child.removeAttribute("slot"));
    getElement().removeAllChildren();
  }
}

代码示例来源:origin: com.vaadin/vaadin-button-flow

/**
 * Removes all contents from this component except elements in
 * {@code exclusion} array. This includes child components, text content as
 * well as child elements that have been added directly to this component
 * using the {@link Element} API.
 *
 * @see Button#removeAll()
 */
private void removeAll(Element... exclusion) {
  Set<Element> toExclude = Stream.of(exclusion)
      .collect(Collectors.toSet());
  Predicate<Element> filter = toExclude::contains;
  getElement().getChildren().filter(filter.negate())
      .forEach(child -> child.removeAttribute("slot"));
  getElement().removeAllChildren();
  getElement().appendChild(exclusion);
}

代码示例来源:origin: com.vaadin/vaadin-button-flow

/**
 * Removes all contents from this component, this includes child components,
 * text content as well as child elements that have been added directly to
 * this component using the {@link Element} API.
 */
protected void removeAll() {
  getElement().getChildren()
      .forEach(child -> child.removeAttribute("slot"));
  getElement().removeAllChildren();
}

代码示例来源:origin: com.vaadin/vaadin-text-field-flow

/**
 * Removes all contents from this component, this includes child components,
 * text content as well as child elements that have been added directly to
 * this component using the {@link Element} API.
 */
protected void removeAll() {
  getElement().getChildren()
      .forEach(child -> child.removeAttribute("slot"));
  getElement().removeAllChildren();
}

代码示例来源:origin: com.vaadin/vaadin-date-picker-flow

/**
 * Removes all contents from this component, this includes child components,
 * text content as well as child elements that have been added directly to
 * this component using the {@link Element} API.
 */
protected void removeAll() {
  getElement().getChildren()
      .forEach(child -> child.removeAttribute("slot"));
  getElement().removeAllChildren();
}

代码示例来源:origin: com.vaadin/vaadin-select-flow

/**
 * Removes all contents from this component, this includes child components,
 * text content as well as child elements that have been added directly to
 * this component using the {@link Element} API.
 */
protected void removeAll() {
  getElement().getChildren()
      .forEach(child -> child.removeAttribute("slot"));
  getElement().removeAllChildren();
}

代码示例来源:origin: com.vaadin/vaadin-text-field-flow

/**
 * Sets the {@link Autocapitalize} attribute for indicating whether the
 * value of this component can be automatically completed by the browser.
 * <p>
 * If not set, devices may apply their own default.
 * <p>
 * <em>Note:</em> <a href=
 * "https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-autocapitalize">This
 * is only supported by Chrome and Safari</a>.
 *
 * @param autocapitalize
 *            the {@code autocapitalize} value, or {@code null} to unset
 */
default void setAutocapitalize(Autocapitalize autocapitalize) {
  if (autocapitalize == null) {
    getElement().removeAttribute(AUTOCAPITALIZE_ATTRIBUTE);
  } else {
    getElement().setAttribute(AUTOCAPITALIZE_ATTRIBUTE,
        autocapitalize.value);
  }
}

代码示例来源:origin: com.vaadin/vaadin-button-flow

/**
 * Set the button so that it is disabled on click.
 * <p>
 * Enabling the button needs to happen from the server.
 *
 * @param disableOnClick
 *            true to disable button immediately when clicked
 */
public void setDisableOnClick(boolean disableOnClick) {
  this.disableOnClick = disableOnClick;
  if (disableOnClick) {
    initDisableOnClick();
    getElement().setAttribute("disableOnClick", "true");
  } else {
    getElement().removeAttribute("disableOnClick");
  }
}

代码示例来源:origin: com.vaadin/vaadin-date-picker-flow

/**
 * Removes the given child components from this component.
 *
 * @param components
 *            The components to remove.
 * @throws IllegalArgumentException
 *             if any of the components is not a child of this component.
 */
protected void remove(Component... components) {
  for (Component component : components) {
    if (getElement().equals(component.getElement().getParent())) {
      component.getElement().removeAttribute("slot");
      getElement().removeChild(component.getElement());
    } else {
      throw new IllegalArgumentException("The given component ("
          + component + ") is not a child of this component");
    }
  }
}

代码示例来源:origin: com.vaadin/vaadin-select-flow

/**
 * Removes the given child components from this component.
 * 
 * @param components
 *            The components to remove.
 * @throws IllegalArgumentException
 *             if any of the components is not a child of this component.
 */
protected void remove(Component... components) {
  for (Component component : components) {
    if (getElement().equals(component.getElement().getParent())) {
      component.getElement().removeAttribute("slot");
      getElement().removeChild(component.getElement());
    } else {
      throw new IllegalArgumentException("The given component ("
          + component + ") is not a child of this component");
    }
  }
}

代码示例来源:origin: com.vaadin/vaadin-button-flow

/**
 * Removes the given child components from this component.
 * 
 * @param components
 *            The components to remove.
 * @throws IllegalArgumentException
 *             if any of the components is not a child of this component.
 */
protected void remove(Component... components) {
  for (Component component : components) {
    if (getElement().equals(component.getElement().getParent())) {
      component.getElement().removeAttribute("slot");
      getElement().removeChild(component.getElement());
    } else {
      throw new IllegalArgumentException("The given component ("
          + component + ") is not a child of this component");
    }
  }
}

代码示例来源:origin: com.vaadin/vaadin-text-field-flow

/**
 * Removes the given child components from this component.
 *
 * @param components
 *            The components to remove.
 * @throws IllegalArgumentException
 *             if any of the components is not a child of this component.
 */
protected void remove(Component... components) {
  for (Component component : components) {
    if (getElement().equals(component.getElement().getParent())) {
      component.getElement().removeAttribute("slot");
      getElement().removeChild(component.getElement());
    } else {
      throw new IllegalArgumentException("The given component ("
          + component + ") is not a child of this component");
    }
  }
}

代码示例来源:origin: com.vaadin/vaadin-upload-flow

/**
 * Removes the given child components from this component.
 *
 * @param components
 *            The components to remove.
 * @throws IllegalArgumentException
 *             if any of the components is not a child of this component.
 */
protected void remove(Component... components) {
  for (Component component : components) {
    if (getElement().equals(component.getElement().getParent())) {
      component.getElement().removeAttribute("slot");
      getElement().removeChild(component.getElement());
    } else {
      throw new IllegalArgumentException("The given component ("
          + component + ") is not a child of this component");
    }
  }
}

代码示例来源:origin: com.vaadin/vaadin-app-layout-flow

private void updateTitleAndIcon(Component icon, String title) {
  removeAll();
  if (icon != null) {
    icon.getElement().setAttribute("role", "img");
    add(icon);
  }
  if (title != null) {
    getElement().setAttribute("title", title);
    add(new Span(title));
  } else {
    getElement().removeAttribute("title");
  }
  this.icon = icon;
  this.title = title;
}

相关文章

微信公众号

最新文章

更多