In late September 2026 LinkedIn started rendering the event and company-page invite dialog inside a shadow root attached to div#interop-outlet. document.querySelector does not cross shadow boundaries, so every lookup for the dialog returned null. The fix: search the regular DOM, then interop-outlet's shadowRoot, then iframes, and pass the root you found to every scraper.
We hit this on a browser extension we maintain that automates LinkedIn event and page invitations. Nothing threw on day one. The extension just started telling users "Invitation dialog window not found" while the dialog sat open in front of them. Below is the exact failure chain, the complete fix we shipped, and the second-order bugs that only showed up after the first fix landed.
What changed in LinkedIn's invite dialog DOM in September 2026?
The invitee-picker modal (div.invitee-picker__modal[role=dialog], and its company-page sibling div.org-invite-to-follow-picker__modal[role=dialog]) moved out of the main document tree. It now renders inside a shadow root hosted by div#interop-outlet. The class names did not change, which is why the selectors looked correct in DevTools while returning null from code.
In the Elements panel you see it clearly once you know to look: <div id="interop-outlet"> followed by a #shadow-root (open) node, with the whole dialog underneath. Before this change, our lookup chain was two steps: regular DOM, then any non-hidden iframe (LinkedIn had already been rendering the same dialog inside an iframe on some page types, which we had handled a year earlier).
The rollout was not uniform. Some sessions still got the old regular-DOM dialog, some got the iframe, and event pages got the shadow-root version first. Any fix has to handle all three at once.
Why does document.querySelector return null for an element you can see?
Shadow DOM is encapsulated by design. document.querySelector and querySelectorAll only walk the light DOM; they never descend into an attached shadow root. To reach the dialog you must first get the host element, read its shadowRoot, and query from there. DevTools' element picker crosses that boundary for you, which hides the problem.
That also means the classic "copy the selector, paste it into document.querySelector in the console" check returns null too. It looks like a selector typo, so the natural reaction is to start rewriting selectors. That is wasted time: the selector is fine, the root is wrong.
There is a second trap. Element.shadowRoot returns null when the root was attached in closed mode. LinkedIn's interop-outlet root is open today, so a plain .shadowRoot read works from a content script. If LinkedIn ever switches it to closed, extensions can still reach it through chrome.dom.openOrClosedShadowRoot(), which returns open or closed roots for a given element.
What did the failure look like in production?
The failure came in two waves. First, the dialog lookup returned null and the extension aborted with its own "dialog not found" message. After we added the shadow-root lookup, the run crashed with TypeError: Cannot read properties of null (reading 'scrollHeight'), because the dialog inside the shadow root has no <main> element to scroll.
Wave one was quiet. Our callers handled a null dialog cleanly, so there was no stack trace, just a toast and an unhappy user. Wave two was loud, which is actually better: the scroll loop read dialogDocument.querySelector("main").scrollHeight on every iteration, and in the shadow-root rendering the scrollable container is the div[role=dialog] itself.
There was also a silent third wave we caught in review. Two helpers, the one that waits for a typed name to appear in results and the one that finds the matching contact <li>, still called document.querySelectorAll(...) directly instead of using the dialog root passed in. In the shadow-root case they returned an empty NodeList, so every contact was skipped with no error at all.
What is the complete fix?
Resolve the dialog's root once, in a fixed order: regular document, then document.querySelector("div#interop-outlet").shadowRoot, then every non-hidden, same-origin iframe's contentDocument. Return whichever root contains the dialog, and thread that root through every downstream query. Never call document.querySelector directly inside dialog code again.
Here is the resolver, reduced from what we shipped (our internal DOM helpers replaced with plain DOM calls):
// Any root you can call querySelector on: Document, ShadowRoot, iframe document.
type DialogRoot = Document | ShadowRoot;
const DIALOG_SELECTORS = [
"div.invitee-picker__modal[role=dialog]",
"div.org-invite-to-follow-picker__modal[role=dialog]",
];
function findIn(root: ParentNode): Element | null {
for (const sel of DIALOG_SELECTORS) {
const el = root.querySelector(sel);
if (el) return el;
}
return null;
}
export function getDialogRoot(): DialogRoot | null {
// 1. Regular DOM (old rendering, still served to some sessions)
if (findIn(document)) return document;
// 2. Shadow DOM hosted at div#interop-outlet (Sep 2026 rendering)
const host = document.querySelector("div#interop-outlet");
const shadow = host?.shadowRoot; // null if the root is closed or not attached yet
if (shadow && findIn(shadow)) return shadow;
// 3. Iframes (skip ones we injected ourselves)
const iframes = document.querySelectorAll<HTMLIFrameElement>(
"iframe:not([data-our-hidden-iframe])"
);
for (const iframe of iframes) {
try {
// Throws on cross-origin frames, so it must be inside try/catch
const doc = iframe.contentDocument ?? iframe.contentWindow?.document;
if (doc && findIn(doc)) return doc;
} catch {
/* cross-origin: not ours to read */
}
}
return null;
}
Order matters. The regular DOM check is cheapest and still the most common case for some sessions. The shadow check is one querySelector plus a property read. Iframes go last because they force a try/catch per frame and LinkedIn pages carry several ad and tracking frames.
Then every scraper takes the root as a parameter instead of reaching for the global:
// Before: silently empty when the dialog lives in a shadow root
const lis = document.querySelectorAll("div.invitee-picker__results-container ul > li");
// After
function getContactLis(root: DialogRoot) {
return root.querySelectorAll<HTMLLIElement>(
"div.invitee-picker__results-container ul > li"
);
}
And the scroll loop resolves its scrollable element once, with a fallback, instead of re-querying main on every iteration:
// Before: crashes with "Cannot read properties of null (reading 'scrollHeight')"
prevScrollHeight = root.querySelector("main").scrollHeight;
root.querySelector("main").scrollBy({ top: 1000, behavior: "smooth" });
// After
const scrollable =
root.querySelector<HTMLElement>("main") ??
root.querySelector<HTMLElement>("div[role=dialog]");
if (!scrollable) throw new Error("Invite dialog has no scrollable container");
prevScrollHeight = scrollable.scrollHeight;
scrollable.scrollBy({ top: 1000, behavior: "smooth" });
Should you cast the ShadowRoot to Document?
We did, as a quick hotfix: shadowRoot as unknown as Document, so every existing function signature kept compiling. It works because the scrapers only call querySelector and querySelectorAll, which ShadowRoot has. It is a lie to the type checker, though, and the type above (Document | ShadowRoot, or just ParentNode) is the honest version.
The reason it matters: a ShadowRoot is a DocumentFragment, not a Document. It has no body, no createElement, no defaultView, no location. With the cast in place, the first helper that touches one of those compiles fine and fails at runtime, only for the users who get the shadow-root rendering. We chose the cast to ship the same evening and accepted that debt knowingly; if you are writing this fresh, type the root as ParentNode and let the compiler find the call sites for you.
What else broke in the same release?
Two more failures surfaced while we were in this code. Contacts who changed job titles after we stored them no longer matched any result row, so the lookup returned null. And every downstream helper dereferenced that null without a guard. We fixed the first with a fallback and the second with optional chaining throughout.
The job-title issue is a data freshness problem, not a DOM problem. We match a typed name against result rows and pick the <li> whose text contains the stored job title, because names collide. When nothing matches, the person most likely updated their headline since we scraped them, so we now fall back to the last matching row instead of skipping:
function getContactLi(jobTitle: string, root: DialogRoot): HTMLLIElement | null {
const lis = getContactLis(root);
if (!lis.length) return null;
for (const li of lis) {
if (li.textContent?.includes(jobTitle)) return li;
}
// Stored job title is stale: accept the last name match (less precise, far more coverage)
return lis[lis.length - 1];
}
That is a deliberate precision-for-recall trade. With a common name and multiple results, the fallback can pick the wrong person. For an invite flow where a wrong pick costs one invite credit and a skip costs a lost invite for every stale record, we took recall. For anything destructive or irreversible, we would not.
The null guards were the follow-up commit the next day. label.parentNode.querySelector(...) became label?.parentNode?.querySelector(...) across the job-title, profile-picture, and label helpers. We also found a clearInterval(timerId) on a setTimeout handle in the stuck-scroll watchdog. Browsers share one ID pool for both, so it worked by accident, but we changed it to clearTimeout.
Why didn't our tests catch the shadow DOM change?
Because the tools we test with pierce shadow DOM for you. Playwright locators work inside open shadow roots by default (XPath excepted), so a Playwright check for the invite dialog keeps passing after LinkedIn's change. The content script uses raw DOM APIs, which do not. Your test and your production code are not exercising the same lookup.
If you drive LinkedIn from a content script, test with the same raw document.querySelector calls the extension makes, or add an assertion that the resolver returned a specific root type. We now log which of the three branches matched on every run. When LinkedIn shifts the rendering again, the distribution of branches changes before users start reporting failures.
For data you only need to read, not click, the UI is the most fragile surface to depend on. We covered the alternative in how to build a production LinkedIn profile scraper with Python and the Voyager API. Invite flows, unfortunately, have to go through the dialog.
The fix in one paragraph
When LinkedIn's invite dialog lives under div#interop-outlet, document.querySelector returns null because it cannot see into shadow roots. Resolve the dialog's root in order (document, the interop-outlet shadow root, iframes), pass that root to every query, replace hardcoded main lookups with a main then div[role=dialog] fallback, and guard every node dereference. The selectors were never the bug; assuming one global document was.