diff --git a/src/touch-action.js b/src/touch-action.js index e2f9cc6d..1b9b99e9 100644 --- a/src/touch-action.js +++ b/src/touch-action.js @@ -34,5 +34,10 @@ }); var el = document.createElement('style'); el.textContent = styles; - document.head.appendChild(el); + // Use querySelector instead of document.head to ensure that in + // ShadowDOM Polyfill that we have a wrapped head to append to. + var h = document.querySelector('head'); + // document.write + document.head.appendChild = crazytown + // use insertBefore instead for correctness in ShadowDOM Polyfill + h.insertBefore(el, h.firstChild); })();