Skip to content

Commit bf2fa0b

Browse files
committedJan 30, 2017
use spaces
1 parent 1edcd38 commit bf2fa0b

File tree

2 files changed

+40
-40
lines changed

2 files changed

+40
-40
lines changed
 

‎index.js

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
2-
MIT License http://www.opensource.org/licenses/mit-license.php
3-
Author Tobias Koppers @sokra
4-
Modified by Evan You @yyx990803
2+
MIT License http://www.opensource.org/licenses/mit-license.php
3+
Author Tobias Koppers @sokra
4+
Modified by Evan You @yyx990803
55
*/
66
var loaderUtils = require('loader-utils')
77
var path = require('path')
@@ -25,32 +25,32 @@ module.exports.pitch = function (remainingRequest) {
2525
'',
2626
'// load the styles',
2727
'var content = require(' + request + ');',
28-
// content list format is [id, css, media, sourceMap]
28+
// content list format is [id, css, media, sourceMap]
2929
"if(typeof content === 'string') content = [[module.id, content, '']];",
3030
'if(content.locals) module.exports = content.locals;'
3131
]
3232

3333
if (!isServer) {
34-
// on the client: dynamic inject + hot-reload
34+
// on the client: dynamic inject + hot-reload
3535
return shared.concat([
3636
'// add the styles to the DOM',
3737
'var update = require(' + addStylesClientPath + ')(' + id + ', content, ' + isProduction + ');',
3838
'// Hot Module Replacement',
3939
'if(module.hot) {',
40-
' // When the styles change, update the <style> tags',
41-
' if(!content.locals) {',
42-
' module.hot.accept(' + request + ', function() {',
43-
' var newContent = require(' + request + ');',
44-
" if(typeof newContent === 'string') newContent = [[module.id, newContent, '']];",
45-
' update(newContent);',
46-
' });',
47-
' }',
48-
' // When the module is disposed, remove the <style> tags',
49-
' module.hot.dispose(function() { update(); });',
40+
' // When the styles change, update the <style> tags',
41+
' if(!content.locals) {',
42+
' module.hot.accept(' + request + ', function() {',
43+
' var newContent = require(' + request + ');',
44+
" if(typeof newContent === 'string') newContent = [[module.id, newContent, '']];",
45+
' update(newContent);',
46+
' });',
47+
' }',
48+
' // When the module is disposed, remove the <style> tags',
49+
' module.hot.dispose(function() { update(); });',
5050
'}'
5151
]).join('\n')
5252
} else {
53-
// on the server: attach to Vue SSR context
53+
// on the server: attach to Vue SSR context
5454
return shared.concat([
5555
'// add CSS to SSR context',
5656
'require(' + addStylesServerPath + ')(' + id + ', content, ' + isProduction + ');'

‎lib/addStylesClient.js

+24-24
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
/*
2-
MIT License http://www.opensource.org/licenses/mit-license.php
3-
Author Tobias Koppers @sokra
4-
Modified by Evan You @yyx990803
2+
MIT License http://www.opensource.org/licenses/mit-license.php
3+
Author Tobias Koppers @sokra
4+
Modified by Evan You @yyx990803
55
*/
66

77
var hasDocument = typeof document !== 'undefined'
88

99
if (typeof DEBUG !== 'undefined' && DEBUG) {
1010
if (!hasDocument) {
1111
throw new Error(
12-
'vue-style-loader cannot be used in a non-browser environment. ' +
13-
"Use { target: 'node' } in your Webpack config to indicate a server-rendering environment."
14-
) }
12+
'vue-style-loader cannot be used in a non-browser environment. ' +
13+
"Use { target: 'node' } in your Webpack config to indicate a server-rendering environment."
14+
) }
1515
}
1616

1717
var listToStyles = require('./listToStyles')
1818

1919
/*
2020
type StyleObject = {
21-
id: number;
22-
parts: Array<StyleObjectPart>
21+
id: number;
22+
parts: Array<StyleObjectPart>
2323
}
2424
2525
type StyleObjectPart = {
@@ -30,11 +30,11 @@ type StyleObjectPart = {
3030
*/
3131

3232
var stylesInDom = {/*
33-
[id: number]: {
34-
id: number,
35-
refs: number,
36-
parts: Array<(obj?: StyleObjectPart) => void>
37-
}
33+
[id: number]: {
34+
id: number,
35+
refs: number,
36+
parts: Array<(obj?: StyleObjectPart) => void>
37+
}
3838
*/}
3939

4040
var head = hasDocument && (document.head || document.getElementsByTagName('head')[0])
@@ -48,7 +48,7 @@ var noop = function () {}
4848
var isOldIE = typeof navigator !== 'undefined' && /msie [6-9]\b/.test(navigator.userAgent.toLowerCase())
4949

5050
module.exports = function (parentId, list, _isProduction) {
51-
isProduction = _isProduction
51+
isProduction = _isProduction
5252

5353
var styles = listToStyles(parentId, list)
5454
addStylesToDom(styles)
@@ -133,19 +133,19 @@ function addStyle (obj /* StyleObjectPart */) {
133133
var hasSSR = styleElement != null
134134

135135
// if in production mode and style is already provided by SSR,
136-
// simply do nothing.
136+
// simply do nothing.
137137
if (hasSSR && isProduction) {
138-
return noop
138+
return noop
139139
}
140140

141141
if (isOldIE) {
142-
// use singleton mode for IE9.
142+
// use singleton mode for IE9.
143143
var styleIndex = singletonCounter++
144144
styleElement = singletonElement || (singletonElement = createStyleElement())
145145
update = applyToSingletonTag.bind(null, styleElement, styleIndex, false)
146146
remove = applyToSingletonTag.bind(null, styleElement, styleIndex, true)
147147
} else {
148-
// use multi-style-tag mode in all other cases
148+
// use multi-style-tag mode in all other cases
149149
styleElement = styleElement || createStyleElement()
150150
update = applyToTag.bind(null, styleElement)
151151
remove = function () {
@@ -154,14 +154,14 @@ function addStyle (obj /* StyleObjectPart */) {
154154
}
155155

156156
if (!hasSSR) {
157-
update(obj)
157+
update(obj)
158158
}
159159

160160
return function updateStyle (newObj /* StyleObjectPart */) {
161161
if (newObj) {
162162
if (newObj.css === obj.css &&
163-
newObj.media === obj.media &&
164-
newObj.sourceMap === obj.sourceMap) {
163+
newObj.media === obj.media &&
164+
newObj.sourceMap === obj.sourceMap) {
165165
return
166166
}
167167
update(obj = newObj)
@@ -207,10 +207,10 @@ function applyToTag (styleElement, obj) {
207207
}
208208

209209
if (sourceMap) {
210-
// https://developer.chrome.com/devtools/docs/javascript-debugging
211-
// this makes source maps inside style tags work properly in Chrome
210+
// https://developer.chrome.com/devtools/docs/javascript-debugging
211+
// this makes source maps inside style tags work properly in Chrome
212212
css += '\n/*# sourceURL=' + sourceMap.sources[0] + ' */'
213-
// http://stackoverflow.com/a/26603875
213+
// http://stackoverflow.com/a/26603875
214214
css += '\n/*# sourceMappingURL=data:application/json;base64,' + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + ' */'
215215
}
216216

0 commit comments

Comments
 (0)