1
1
/*
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
5
5
*/
6
6
7
7
var hasDocument = typeof document !== 'undefined'
8
8
9
9
if ( typeof DEBUG !== 'undefined' && DEBUG ) {
10
10
if ( ! hasDocument ) {
11
11
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
+ ) }
15
15
}
16
16
17
17
var listToStyles = require ( './listToStyles' )
18
18
19
19
/*
20
20
type StyleObject = {
21
- id: number;
22
- parts: Array<StyleObjectPart>
21
+ id: number;
22
+ parts: Array<StyleObjectPart>
23
23
}
24
24
25
25
type StyleObjectPart = {
@@ -30,11 +30,11 @@ type StyleObjectPart = {
30
30
*/
31
31
32
32
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
+ }
38
38
*/ }
39
39
40
40
var head = hasDocument && ( document . head || document . getElementsByTagName ( 'head' ) [ 0 ] )
@@ -48,7 +48,7 @@ var noop = function () {}
48
48
var isOldIE = typeof navigator !== 'undefined' && / m s i e [ 6 - 9 ] \b / . test ( navigator . userAgent . toLowerCase ( ) )
49
49
50
50
module . exports = function ( parentId , list , _isProduction ) {
51
- isProduction = _isProduction
51
+ isProduction = _isProduction
52
52
53
53
var styles = listToStyles ( parentId , list )
54
54
addStylesToDom ( styles )
@@ -133,19 +133,19 @@ function addStyle (obj /* StyleObjectPart */) {
133
133
var hasSSR = styleElement != null
134
134
135
135
// if in production mode and style is already provided by SSR,
136
- // simply do nothing.
136
+ // simply do nothing.
137
137
if ( hasSSR && isProduction ) {
138
- return noop
138
+ return noop
139
139
}
140
140
141
141
if ( isOldIE ) {
142
- // use singleton mode for IE9.
142
+ // use singleton mode for IE9.
143
143
var styleIndex = singletonCounter ++
144
144
styleElement = singletonElement || ( singletonElement = createStyleElement ( ) )
145
145
update = applyToSingletonTag . bind ( null , styleElement , styleIndex , false )
146
146
remove = applyToSingletonTag . bind ( null , styleElement , styleIndex , true )
147
147
} else {
148
- // use multi-style-tag mode in all other cases
148
+ // use multi-style-tag mode in all other cases
149
149
styleElement = styleElement || createStyleElement ( )
150
150
update = applyToTag . bind ( null , styleElement )
151
151
remove = function ( ) {
@@ -154,14 +154,14 @@ function addStyle (obj /* StyleObjectPart */) {
154
154
}
155
155
156
156
if ( ! hasSSR ) {
157
- update ( obj )
157
+ update ( obj )
158
158
}
159
159
160
160
return function updateStyle ( newObj /* StyleObjectPart */ ) {
161
161
if ( newObj ) {
162
162
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 ) {
165
165
return
166
166
}
167
167
update ( obj = newObj )
@@ -207,10 +207,10 @@ function applyToTag (styleElement, obj) {
207
207
}
208
208
209
209
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
212
212
css += '\n/*# sourceURL=' + sourceMap . sources [ 0 ] + ' */'
213
- // http://stackoverflow.com/a/26603875
213
+ // http://stackoverflow.com/a/26603875
214
214
css += '\n/*# sourceMappingURL=data:application/json;base64,' + btoa ( unescape ( encodeURIComponent ( JSON . stringify ( sourceMap ) ) ) ) + ' */'
215
215
}
216
216
0 commit comments