Skip to content

Note that Attr.isConnected is always false#44349

Open
vamshikrishnaramasamy wants to merge 1 commit into
mdn:mainfrom
vamshikrishnaramasamy:docs/issue-42933-attr-isconnected
Open

Note that Attr.isConnected is always false#44349
vamshikrishnaramasamy wants to merge 1 commit into
mdn:mainfrom
vamshikrishnaramasamy:docs/issue-42933-attr-isconnected

Conversation

@vamshikrishnaramasamy
Copy link
Copy Markdown
Contributor

Fixes #42933.

isConnected always returns false on an {{domxref("Attr")}} node, even when the attribute's ownerElement is connected to the document. This trips people up, so this adds a note explaining why.

As @caugner noted on the issue, this is consistent across Chrome, Firefox, and Safari, and is out of scope for BCD — the spec defines isConnected for all nodes, and since an attribute node has no parent, it has no root that is a document, so it is never "connected".

I confirmed the behavior in Chrome:

const el = document.createElement("div");
el.setAttribute("data-x", "1");
const attr = el.getAttributeNode("data-x");
document.body.appendChild(el);

el.isConnected;                 // true
attr.ownerElement.isConnected;  // true
attr.isConnected;               // false
attr.parentNode;                // null
attr.getRootNode() === attr;    // true (its root is itself, not the document)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vamshikrishnaramasamy vamshikrishnaramasamy requested a review from a team as a code owner June 4, 2026 01:22
@vamshikrishnaramasamy vamshikrishnaramasamy requested review from chrisdavidmills and removed request for a team June 4, 2026 01:22
@github-actions github-actions Bot added Content:WebAPI Web API docs size/s [PR only] 6-50 LoC changed labels Jun 4, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 4, 2026

Preview URLs (1 page)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Content:WebAPI Web API docs size/s [PR only] 6-50 LoC changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

api.Node.isConnected - Attr.isConnected is always false

2 participants