Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds option to customize stylesheet attachment. #84

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ viewportUnitsBuggyfill.init({refreshDebounceWait: 250});
//
viewportUnitsBuggyfill.init({hacks: window.viewportUnitsBuggyfillHacks});

// append the patched stylesheet to body instead of head
viewportUnitsBuggyfill.init({appendToBody: true});

// update internal declarations cache and recalculate pixel styles
// this is handy when you add styles after .init() was run
viewportUnitsBuggyfill.refresh();
Expand Down
6 changes: 4 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</style>
</head>
<body>

<p><strong>Note:</strong> this script will only work with browsers that have buggy implementations of viewport units and will not polyfill viewport units in older browsers (e.g. IE &lt;= 8)</p>
<script src="viewport-units-buggyfill.js"></script>
<script src="viewport-units-buggyfill.hacks.js"></script>
Expand All @@ -33,7 +33,9 @@
// milliseconds to delay between updates of viewport-units
// caused by orientationchange, pageshow, resize events
refreshDebounceWait: 250,
hacks: window.viewportUnitsBuggyfillHacks
hacks: window.viewportUnitsBuggyfillHacks,
// append to body
appendToBody: true
});</script>
</body>
</html>
2 changes: 1 addition & 1 deletion viewport-units-buggyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
initialized = true;
styleNode = document.createElement('style');
styleNode.id = 'patched-viewport';
document.head.appendChild(styleNode);
document[options.appendToBody ? 'body' : 'head'].appendChild(styleNode);

// Issue #6: Cross Origin Stylesheets are not accessible through CSSOM,
// therefore download and inject them as <style> to circumvent SOP.
Expand Down