From 2644676602dfcf1134f7600e3a2a51135704cc06 Mon Sep 17 00:00:00 2001 From: Ian K Smith Date: Mon, 14 Oct 2019 16:19:14 -0600 Subject: [PATCH 1/2] Use CSSOM instead of 'setAttribute' to avoid CSP issues --- src/lib.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) 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: From 4f9ecc1b448eb5cc24731e4ec7aef0411ad8e49f Mon Sep 17 00:00:00 2001 From: Ian K Smith Date: Mon, 14 Oct 2019 16:31:59 -0600 Subject: [PATCH 2/2] v2.0.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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",