Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit12408a3

Browse files
committed
Only match full wordinitial occurrences
I had an animation named `initiallyHide`, and noticed the compiledoutput contained:```cssanimation: 0s ease 0s 1 none runninglyHide 1s linear 0s 1 normal none;```So the `initial` in `initiallyHide` was replaced with `running`.This patch changes the replace regex to only match on word boundaries.
1 parent25e7c4d commit12408a3

File tree

5 files changed

+14
-2
lines changed

5 files changed

+14
-2
lines changed

‎index.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module.exports = postcss.plugin('postcss-initial', function (opts) {
1717
};
1818
returnfunction(css){
1919
css.walkDecls(function(decl){
20-
if(decl.value.indexOf('initial')<0){
20+
if(!/\binitial\b/.test(decl.value)){
2121
return;
2222
}
2323
varfallBackRules=getFallback(decl.prop,decl.value);

‎lib/rules-fabric.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ function _clearDecls(rules, value) {
6262
returnrules.map(function(rule){
6363
return{
6464
prop:rule.prop,
65-
value:value.replace(/initial/g,rule.initial)
65+
value:value.replace(/\binitial\b/g,rule.initial)
6666
};
6767
});
6868
}

‎test/fixtures/negative.css‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
a {
2+
animation: initiallyHidden1s linear0s1;
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
a {
2+
animation: initiallyHidden1s linear0s1;
3+
}

‎test/index.js‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,10 @@ describe('postcss-initial', function () {
7474
{replace:true}
7575
);
7676
});
77+
it('negative',function(){
78+
test(
79+
f('negative'),
80+
f('negative.expected')
81+
);
82+
});
7783
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp