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

Commit

Permalink
Merge pull request #21 from hanachin/insert-before-pseudo
Browse files Browse the repository at this point in the history
Insert attribute selector right before Pseudo-classes
  • Loading branch information
yyx990803 committed Oct 30, 2015
2 parents 034e4e2 + c42b314 commit b6e4e25
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/style-rewriter.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ var addId = postcss.plugin('add-id', function () {
root.each(function (node) {
node.selector = selectorParser(function (selectors) {
selectors.each(function (selector) {
selector.append(selectorParser.attribute({
var node = null
selector.each(function (n) {
if (n.type !== 'pseudo') node = n
})
selector.insertAfter(node, selectorParser.attribute({
attribute: currentId
}))
})
Expand Down
2 changes: 1 addition & 1 deletion test/expects/scoped.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
var __vueify_style__ = require("vueify-insert-css").insert("div[{{id}}]{color:red}.test[{{id}}]{color:green}")
var __vueify_style__ = require("vueify-insert-css").insert("div[{{id}}]{color:red}.test[{{id}}]{color:green}.test[{{id}}]:after{content:'bye!'}")
;(typeof module.exports === "function"? module.exports.options: module.exports).template = "<div {{id}}=\"\">hi<p class=\"test\" {{id}}=\"\">bye</p></div>"
1 change: 1 addition & 0 deletions test/fixtures/scoped.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<style scoped>
div { color: red; }
.test { color: green; }
.test:after { content: 'bye!'; }
</style>

<template>
Expand Down

0 comments on commit b6e4e25

Please sign in to comment.