From 074785cea106179cb3305637055ab0a009ca74f2 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:42:52 -0500 Subject: initial commit --- files/ru/web/api/node/isconnected/index.html | 87 ++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 files/ru/web/api/node/isconnected/index.html (limited to 'files/ru/web/api/node/isconnected') diff --git a/files/ru/web/api/node/isconnected/index.html b/files/ru/web/api/node/isconnected/index.html new file mode 100644 index 0000000000..aef8cf8ee7 --- /dev/null +++ b/files/ru/web/api/node/isconnected/index.html @@ -0,0 +1,87 @@ +--- +title: Node.isConnected +slug: Web/API/Node/isConnected +translation_of: Web/API/Node/isConnected +--- +

{{APIRef("DOM")}}

+ +

The isConnected read-only property of the {{domxref("Node")}} interface returns a boolean indicating whether the Node is connected (directly or indirectly) to the context object, for example the {{domxref("Document")}} object in the case of the normal DOM, or the {{domxref("ShadowRoot")}} in the case of a shadow DOM.

+ +

Синтаксис

+ +
var isItConnected = nodeObjectInstance.isConnected
+ +

Return value

+ +

A {{domxref("Boolean")}} that is true if the node is connected to its relevant context object, and false if not.

+ +

Пример

+ +

Стандартный DOM пример:

+ +
let test = document.createElement('p');
+console.log(test.isConnected); // returns false
+document.body.appendChild(test);
+console.log(test.isConnected); // returns true
+
+ +

A shadow DOM example:

+ +
// Create a shadow root
+var shadow = this.attachShadow({mode: 'open'});
+
+// Create some CSS to apply to the shadow dom
+var 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;' +
+                        'position: 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
+ +

 

+ +

Спецификация

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('DOM WHATWG','#dom-node-isconnected','isConnected')}}{{Spec2('DOM WHATWG')}}Initial definition.
+ +

Поддержка Браузерами

+ +
+ + +

{{Compat("api.Node.isConnected")}}

+
-- cgit v1.2.3-54-g00ecf