Skip to content

Instantly share code, notes, and snippets.

@chaorace
Created July 12, 2023 16:05
Show Gist options
  • Save chaorace/ccaaa3f3968677f06922db1331faa84e to your computer and use it in GitHub Desktop.
Save chaorace/ccaaa3f3968677f06922db1331faa84e to your computer and use it in GitHub Desktop.
Subframe element issue reproduction steps @ qutebrowser/qutebrowser#7617
<html>
<body>
<button type="button" onclick="clicked(this)">IFrame Button</button>
<div id="shadow-root"></div>
<script>
function clicked(element){ element.innerHTML = 'Clicked' }
const shadow = document.getElementById('shadow-root').attachShadow({ mode: 'open' })
const shadowButton = document.createElement('button')
shadowButton.type = 'button"'
shadowButton.innerHTML = 'IFrame Shadow Button'
shadowButton.onclick = function(){ clicked(this) }
shadow.appendChild(shadowButton)
</script>
</body>
</html>
<html>
<body>
<button type="button" onclick="clicked(this)">Normal Button</button>
<div id="shadow-root"></div>
<script>
function clicked(element){ element.innerHTML = 'Clicked' }
const shadow = document.getElementById('shadow-root').attachShadow({ mode: 'open' })
const shadowButton = document.createElement('button')
shadowButton.type = 'button'
shadowButton.innerHTML = 'Shadow Button'
shadowButton.onclick = function(){ clicked(this) }
shadow.appendChild(shadowButton)
</script>
<iframe src="./example-iframe.html">
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment