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

Commit

Permalink
Insert attribute selector right before Pseudo-classes
Browse files Browse the repository at this point in the history
  • Loading branch information
hanachin committed Oct 30, 2015
1 parent 034e4e2 commit c42b314
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 c42b314

Please sign in to comment.