A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://developer.mozilla.org/ja/docs/Web/API/Window/customElements below:

Window: customElements プãƒãƒ‘ティ - Web API

Window: customElements プロパティ

Baseline Widely available

customElements は Window インターフェイスの読み取り専用プロパティで、 CustomElementRegistry オブジェクトへのリファレンスを返します。これにより、新しいカスタム要素を登録したり、以前に登録したカスタム要素に関する情報を取得したりすることができます。

例

このプロパティが使われている最も一般的な例は、新しいカスタム要素を定義・登録するために CustomElementRegistry.define() メソッドにアクセスすることです。例えば次のようにします。

let customElementRegistry = window.customElements;
customElementRegistry.define("my-custom-element", MyCustomElement);

しかし、ふつうは以下のように短縮します。

customElements.define(
  "element-details",
  class extends HTMLElement {
    constructor() {
      super();
      const template = document.getElementById(
        "element-details-template",
      ).content;
      const shadowRoot = this.attachShadow({ mode: "open" }).appendChild(
        template.cloneNode(true),
      );
    }
  },
);

web-components-examples リポジトリーにより多くの使用例がありますので参照してください。

仕様書 ブラウザーの互換性

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4