From d4ca275b1229942dca73b4c4ed27a50f893dd6c9 Mon Sep 17 00:00:00 2001 From: Daniel Freedman Date: Fri, 26 Apr 2013 14:35:07 -0700 Subject: [PATCH] Fix inserting touch action stylesheet for Shadow DOM Polyfill --- src/touch-action.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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); })();