I have code like this, which selects a specific meta tag from the document. What I’m expecting from this code is to select and fetch the first tag out of the many tags in the head.
This code has been working fine until now, but something happened to select the meta tag inside the iframe’s shadowDOM instead. As far as I know, the iframe works independently and is not accessible, so why would I want to access it?
The querySelector is looking for the first element, so even if I had access to the iframe, wouldn’t the element in the head be the first?
const getDisplayLocation = () => {
return window.document.querySelector('meta[name="temp_role"]').content;
};
I suspect window.document is the reason this is happening, but I haven’t found the exact cause.
장유진 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.