8000 pass query.id as an option to addId in style-rewriter (#237) · rspack-contrib/rspack-vue-loader@8951234 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8951234

Browse files
Giumo X. Clanjor (哆啦比猫/兰威举)yyx990803
Giumo X. Clanjor (哆啦比猫/兰威举)
authored andcommitted
pass query.id as an option to addId in style-rewriter (vuejs#237)
- removed global variable "currentId" - query.id is passed as an option to addId
1 parent 6ee7aaa commit 8951234

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

lib/style-rewriter.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ var selectorParser = require('postcss-selector-parser')
33
var loaderUtils = require('loader-utils')
44
var assign = require('object-assign')
55

6-
var currentId
7-
var addId = postcss.plugin('add-id', function () {
6+
var addId = postcss.plugin('add-id', function (opts) {
87
return function (root) {
98
root.each(function rewriteSelector (node) {
109
if (!node.selector) {
@@ -21,7 +20,7 @@ var addId = postcss.plugin('add-id', function () {
2120
if (n.type !== 'pseudo') node = n
2221
})
2322
selector.insertAfter(node, selectorParser.attribute({
24-
attribute: currentId
23+
attribute: opts.id
2524
}))
2625
})
2726
}).process(node.selector).result
@@ -46,7 +45,7 @@ module.exports = function (css, map) {
4645

4746
// scoped css
4847
if (query.scoped) {
49-
plugins.push(addId)
48+
plugins.push(addId({ id: query.id }))
5049
}
5150

5251
// autoprefixer
@@ -82,7 +81,6 @@ module.exports = function (css, map) {
8281
}
8382
}
8483

85-
currentId = query.id
8684
postcss(plugins)
8785
.process(css, opts)
8886
.then(function (result) {

0 commit comments

Comments
 (0)
0