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

Merge pull request #1393 from sveltejs/bind-width-etc

allow destruction of components with bind:offsetWidth etc
This commit is contained in:
Rich Harris 2018-04-30 21:37:01 -04:00 committed by GitHub
commit 0d3984a2ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 4 deletions

View File

@ -203,8 +203,11 @@ export function addResizeListener(element, fn) {
object.setAttribute('style', 'display: block; position: absolute; top: 0; left: 0; height: 100%; width: 100%; overflow: hidden; pointer-events: none; z-index: -1;');
object.type = 'text/html';
let win;
object.onload = () => {
object.contentDocument.defaultView.addEventListener('resize', fn);
win = object.contentDocument.defaultView;
win.addEventListener('resize', fn);
};
if (/Trident/.test(navigator.userAgent)) {
@ -217,7 +220,7 @@ export function addResizeListener(element, fn) {
return {
cancel: () => {
object.contentDocument.defaultView.removeEventListener('resize', fn);
win.removeEventListener('resize', fn);
element.removeChild(object);
}
};

View File

@ -26,8 +26,11 @@ function addResizeListener(element, fn) {
object.setAttribute('style', 'display: block; position: absolute; top: 0; left: 0; height: 100%; width: 100%; overflow: hidden; pointer-events: none; z-index: -1;');
object.type = 'text/html';
let win;
object.onload = () => {
object.contentDocument.defaultView.addEventListener('resize', fn);
win = object.contentDocument.defaultView;
win.addEventListener('resize', fn);
};
if (/Trident/.test(navigator.userAgent)) {
@ -40,7 +43,7 @@ function addResizeListener(element, fn) {
return {
cancel: () => {
object.contentDocument.defaultView.removeEventListener('resize', fn);
win.removeEventListener('resize', fn);
element.removeChild(object);
}
};