[Edge]。→、
element の ElementInternals オブジェクトを返します。
このメソッドを使用すると、カスタム要素をHTMLフォームに参加させることができます。
ElementInternals インターフェイスは、標準の HTML フォーム要素を操作するのと同じ方法でこれらの要素を操作するためのユーティリティを提供し、アクセシビリティ オブジェクト モデルを要素に公開します。
| element | ¶HTMLElement。(カスタム要素?) |
|---|
次の例は、HTMLElement.attachInternals を使用してカスタムフォーム関連要素を作成する方法を示しています。次に、ElementInternals.form プロパティがコンソールに出力され、ElementInternals オブジェクトがあることを示します。
class CustomCheckbox extends HTMLElement {
static formAssociated = true;
constructor() {
super();
this.internals_ = this.attachInternals();
}
/* ... */
window.customElements.define("custom-checkbox", CustomCheckbox);
})();
let element = document.getElementById("custom-checkbox");
console.log(element.internals_.form);