Skip to content
This repository was archived by the owner on Jan 18, 2022. It is now read-only.

Fix #101, check for existence of document before injecting css #114

Merged
merged 2 commits into from
Jul 24, 2017
Merged
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
2 changes: 1 addition & 1 deletion src/vueTransform.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ export default async function vueTransform (code, id, options) {
const style = css.map(s => '$compiled' in s ? s.$compiled.code : s.code).join('\n').replace(/(\r?\n|[\s])+/g, ' ')
const styleCode = `
(function(){
if(document){
if(typeof document !== 'undefined'){
var head=document.head||document.getElementsByTagName('head')[0],
style=document.createElement('style'),
css=${JSON.stringify(style)};
Expand Down
2 changes: 1 addition & 1 deletion test/expects/no-css-extract.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(function(){ if(document){ var head=document.head||document.getElementsByTagName('head')[0], style=document.createElement('style'), css=".baz { color: #008000; } .bar { color: blue } .foo { color: red; } "; style.type='text/css'; if (style.styleSheet){ style.styleSheet.cssText = css; } else { style.appendChild(document.createTextNode(css)); } head.appendChild(style); } })();
(function(){ if(typeof document !== 'undefined'){ var head=document.head||document.getElementsByTagName('head')[0], style=document.createElement('style'), css=".baz { color: #008000; } .bar { color: blue } .foo { color: red; } "; style.type='text/css'; if (style.styleSheet){ style.styleSheet.cssText = css; } else { style.appendChild(document.createTextNode(css)); } head.appendChild(style); } })();



Expand Down