Skip to content

Commit c826475

Browse files
committed
modify the scopeId
1 parent fda7ee7 commit c826475

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

lib/loader.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,9 @@ module.exports = function (content) {
209209
}
210210

211211
var parts = parse(content, fileName, this.sourceMap)
212-
var hasScoped = parts.styles.some(function (s) { return s.scoped })
213-
var scopeId = hasScoped ? genId(filePath) : '@GLOBAL'
212+
// var hasGlobal = parts.styles.some(function (s) { return !!s.global })
213+
// var scopeId = hasGlobal ? '@GLOBAL' : genId(filePath)
214+
var scopeId = genId(filePath)
214215
var output = 'var __vue_exports__, __vue_options__\n'
215216

216217
// css modules
@@ -305,7 +306,9 @@ module.exports = function (content) {
305306
}
306307

307308
// attach scoped id
308-
exports += '__vue_options__._scopeId = "' + scopeId + '"\n'
309+
if (parts.styles.length) {
310+
exports += '__vue_options__._scopeId = "' + scopeId + '"\n'
311+
}
309312

310313
// if (Object.keys(cssModules).length) {
311314
// // inject style modules as computed properties

lib/parser.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// TODO: use weex-tempalte-compiler
12
var compiler = require('vue-template-compiler')
23
var cache = require('lru-cache')(100)
34
var hash = require('hash-sum')
@@ -12,6 +13,7 @@ module.exports = function (content, filename, needMap) {
1213
var filenameWithHash = filename + '?' + cacheKey
1314
var output = cache.get(cacheKey)
1415
if (output) return output
16+
// TODO: support to use "global" in <style>
1517
output = compiler.parseComponent(content, { pad: true })
1618
if (needMap) {
1719
if (output.script && !output.script.src) {

0 commit comments

Comments
 (0)