diff --git a/package.json b/package.json index 866ea53..8c86125 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "watch-resize", - "version": "2.0.1", + "version": "2.0.2", "description": "Watch any DOM element for size changes using Observables.", "author": "Ian K Smith ", "license": "MIT", diff --git a/src/lib.ts b/src/lib.ts index e46269e..1e05e92 100644 --- a/src/lib.ts +++ b/src/lib.ts @@ -73,13 +73,22 @@ export function watchResize( // Create a nested browsing context using an element. const obj = document.createElement('object'); - obj.setAttribute( - 'style', - 'display: block; position: absolute; top: 0; left: 0; height: 100%; width: 100%; overflow: hidden; pointer-events: none; z-index: -1;', - ); + + // Set type and data obj.type = 'text/html'; obj.data = 'about:blank'; + // Set CSSOM properties + obj.style.display = 'block'; + obj.style.position = 'absolute'; + obj.style.top = '0'; + obj.style.left = '0'; + obj.style.height = '100%'; + obj.style.width = '100%'; + obj.style.overflow = 'hidden'; + obj.style.pointerEvents = 'none'; + obj.style.zIndex = '-1'; + // Store some data that will change with the observable. const subscribers: Subscriber>[] = []; let prevBoundingClientRect: