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

Insert attribute selector right before Pseudo-classes #21

Merged
merged 1 commit into from
Oct 30, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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