STR: - open the devtools window (the web console for example) - start the scratchpad (browser environment) - execute this code: let iframe = document.getElementById("devtools-toolbox-bottom-iframe"); let CLASS_NAME = "foobar"; iframe.className = CLASS_NAME; iframe.setAttribute("class", CLASS_NAME); // trying both ways alert("why is this null: " + document.querySelector("." + CLASS_NAME)); alert("... and this is true: " + iframe.mozMatchesSelector("." + CLASS_NAME)); alert("... and this undefined: " + document.getElementsByClassName(CLASS_NAME)); - expected result: XULNode / true / XULNode - actual result: null / true / undefined
It appears to be specific to the devtools-toolbox-bottom-iframe, that is created here: http://mxr.mozilla.org/mozilla-central/source/browser/devtools/framework/ToolboxHosts.jsm#56
I think this is actually an expected behavior because the iframe is an anonymous node.
Status: NEW → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → INVALID
Yes, exactly. getElementById on XUL document is a glaring spec violation in that it returns anonymous things, unfortunately; I tried to fix that at one point but ran into all sorts of chrome code relying on the behavior. :(
You need to log in before you can comment on or make changes to this bug.