File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -204,6 +204,12 @@ function localizeDeclNode(node, context) {
204204 return node ;
205205}
206206
207+ function isWordAFunctionArgument ( wordNode , functionNode ) {
208+ return functionNode
209+ ? functionNode . nodes . some ( functionNodeChild => functionNodeChild . sourceIndex === wordNode . sourceIndex )
210+ : false
211+ }
212+
207213function localizeAnimationShorthandDeclValues ( decl , context ) {
208214 const validIdent = / ^ - ? [ _ a - z ] [ _ a - z 0 - 9 - ] * $ / i;
209215
@@ -244,13 +250,19 @@ function localizeAnimationShorthandDeclValues(decl, context) {
244250
245251 const didParseAnimationName = false ;
246252 let parsedAnimationKeywords = { } ;
253+ let stepsFunctionNode = null ;
247254 const valueNodes = valueParser ( decl . value ) . walk ( ( node ) => {
248255 /* If div-token appeared (represents as comma ','), a possibility of an animation-keywords should be reflesh. */
249256 if ( node . type === 'div' ) {
250257 parsedAnimationKeywords = { } ;
251258 }
259+ if ( node . type === 'function' && node . value . toLowerCase ( ) === 'steps' ) {
260+ stepsFunctionNode = node ;
261+ }
252262 const value =
253- node . type === 'word' ? node . value . toLowerCase ( ) : null ;
263+ node . type === 'word' && ! isWordAFunctionArgument ( node , stepsFunctionNode )
264+ ? node . value . toLowerCase ( )
265+ : null ;
254266
255267 let shouldParseAnimationName = false ;
256268
Original file line number Diff line number Diff line change @@ -198,6 +198,23 @@ const tests = [
198198 expected :
199199 ':local(.foo) { animation: :local(slide-right) 300ms forwards ease-out, :local(fade-in) 300ms forwards ease-out; }'
200200 } ,
201+ {
202+ should :
203+ 'not treat "start" and "end" keywords in steps() function as identifiers' ,
204+ input : [
205+ '.foo { animation: spin 1s steps(12, end) infinite; }' ,
206+ '.foo { animation: spin 1s STEPS(12, start) infinite; }' ,
207+ '.foo { animation: spin 1s steps(12, END) infinite; }' ,
208+ '.foo { animation: spin 1s steps(12, START) infinite; }' ,
209+ ] . join ( '\n' ) ,
210+ expected :
211+ [
212+ ':local(.foo) { animation: :local(spin) 1s steps(12, end) infinite; }' ,
213+ ':local(.foo) { animation: :local(spin) 1s STEPS(12, start) infinite; }' ,
214+ ':local(.foo) { animation: :local(spin) 1s steps(12, END) infinite; }' ,
215+ ':local(.foo) { animation: :local(spin) 1s steps(12, START) infinite; }'
216+ ] . join ( '\n' ) ,
217+ } ,
201218 {
202219 should : 'handle animations with custom timing functions' ,
203220 input :
You can’t perform that action at this time.
0 commit comments