0
0
mirror of https://github.com/sveltejs/svelte.git synced 2024-12-01 17:30:59 +01:00

use iframe z-index: -1 in resize listener (#5742)

This commit is contained in:
Nick Vincent 2021-01-01 17:56:26 -08:00 committed by GitHub
parent 1da4105d65
commit f7d4eef55d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 2 deletions

View File

@ -261,7 +261,6 @@ export function is_crossorigin() {
export function add_resize_listener(node: HTMLElement, fn: () => void) {
const computed_style = getComputedStyle(node);
const z_index = (parseInt(computed_style.zIndex) || 0) - 1;
if (computed_style.position === 'static') {
node.style.position = 'relative';
@ -270,7 +269,7 @@ export function add_resize_listener(node: HTMLElement, fn: () => void) {
const iframe = element('iframe');
iframe.setAttribute('style',
'display: block; position: absolute; top: 0; left: 0; width: 100%; height: 100%; ' +
`overflow: hidden; border: 0; opacity: 0; pointer-events: none; z-index: ${z_index};`
'overflow: hidden; border: 0; opacity: 0; pointer-events: none; z-index: -1;'
);
iframe.setAttribute('aria-hidden', 'true');
iframe.tabIndex = -1;

View File

@ -0,0 +1,7 @@
export default {
async test({ assert, target }) {
const iframe = target.querySelector('iframe');
assert.equal(iframe.style.zIndex, '-1');
}
};

View File

@ -0,0 +1,8 @@
<script>
let offsetWidth = 0;
let offsetHeight = 0;
</script>
<div style="z-index: 42;" bind:offsetHeight bind:offsetWidth>
<h1>Hello</h1>
</div>