Skip to content
This repository was archived by the owner on Dec 26, 2018. It is now read-only.

Commit b6e4e25

Browse files
committed
Merge pull request #21 from hanachin/insert-before-pseudo
Insert attribute selector right before Pseudo-classes
2 parents 034e4e2 + c42b314 commit b6e4e25

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

lib/style-rewriter.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ var addId = postcss.plugin('add-id', function () {
99
root.each(function (node) {
1010
node.selector = selectorParser(function (selectors) {
1111
selectors.each(function (selector) {
12-
selector.append(selectorParser.attribute({
12+
var node = null
13+
selector.each(function (n) {
14+
if (n.type !== 'pseudo') node = n
15+
})
16+
selector.insertAfter(node, selectorParser.attribute({
1317
attribute: currentId
1418
}))
1519
})

test/expects/scoped.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
var __vueify_style__ = require("vueify-insert-css").insert("div[{{id}}]{color:red}.test[{{id}}]{color:green}")
1+
var __vueify_style__ = require("vueify-insert-css").insert("div[{{id}}]{color:red}.test[{{id}}]{color:green}.test[{{id}}]:after{content:'bye!'}")
22
;(typeof module.exports === "function"? module.exports.options: module.exports).template = "<div {{id}}=\"\">hi<p class=\"test\" {{id}}=\"\">bye</p></div>"

test/fixtures/scoped.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<style scoped>
22
div { color: red; }
33
.test { color: green; }
4+
.test:after { content: 'bye!'; }
45
</style>
56

67
<template>

0 commit comments

Comments
 (0)