Skip to content

Commit dc84e3e

Browse files
committed
fixed .attribute[] regex for css
1 parent 644b169 commit dc84e3e

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

lib/utils/options/fileReplace.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,15 @@ fileReplace.replace = (filepath, options, cb) => {
8383
fileReplace.replaceCss = (filepath, options, cb) => {
8484
let result;
8585
// matches from . or # every character until : or . or ) (for pseudo elements or dots or even in :not(.class))
86-
let regex = /(#|\.)[^\s:\.\{)]+/g;
86+
let regex = /(#|\.)[^\s:\.\{)[]+/g;
8787

8888
// set cb if options are not set
8989
if (typeof cb !== 'function') {
9090
cb = options;
9191
options = {};
9292
}
9393

94-
fs.readFile(filepath, 'utf8', (err, data) => {
94+
fs.readFile (filepath, 'utf8', (err, data) => {
9595
if (err || data.length === 0) {
9696
return cb ({
9797
message: 'File does not exist or is empty',

test/files/fixtures/style.css

+4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
content: 'id';
2727
}
2828

29+
.jp-attribute[src] {
30+
content: 'attribute';
31+
}
32+
2933
h1 {
3034
color: red;
3135
}

test/files/results/style.css

+4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
content: 'id';
2727
}
2828

29+
.g[src] {
30+
content: 'attribute';
31+
}
32+
2933
h1 {
3034
color: red;
3135
}

0 commit comments

Comments
 (0)