[Edge]。読取専用。→、、
mdn: ノードがコンテキストオブジェクト、例えば、通常の DOM の場合は Document オブジェクト、シャドウ DOM の場合は ShadowRoot に(直接的または間接的に)接続されているかどうかを示す論理値を返します。
Node | Node オブジェクト。 |
---|
論理値。true:このノードが関連するコンテキスト オブジェクトに接続されていることを表す。false:接続していないことを表します。
let test = document.createElement('p'); console.log(test.isConnected); // Returns false document.body.appendChild(test); console.log(test.isConnected); // Returns true
// Create a shadow root const shadow = this.attachShadow({mode: 'open'}); // Create some CSS to apply to the shadow dom const style = document.createElement('style'); console.log(style.isConnected); // returns false style.textContent = ` .wrapper { position: relative; } .info { font-size: 0.8rem; width: 200px; display: inline-block; border: 1px solid black; padding: 10px; background: white; border-radius: 10px; opacity: 0; transition: 0.6s all; positions: absolute; bottom: 20px; left: 10px; z-index: 3 } `; // Attach the created style element to the shadow dom shadow.appendChild(style); console.log(style.isConnected); // Returns true
¶以下省く