@@ -49,16 +49,25 @@ def skip_whitespace(nodes):
4949 return filter (lambda node : node .type != "whitespace" , nodes )
5050
5151
52+ SHADOW_CSS_PROPERTIES = {
53+ "box-shadow" ,
54+ "text-shadow" ,
55+ }
56+
57+
5258def has_shadow (rule ):
5359 if not rule .content :
5460 return False
5561
5662 for a , b , c in tripletwise (skip_whitespace (rule .content )):
57- if isinstance (a , tokens .IdentToken ) and a .value == "box-shadow" :
63+ if isinstance (a , tokens .IdentToken ) and a .value in SHADOW_CSS_PROPERTIES :
5864 assert isinstance (
5965 c , (tokens .IdentToken , tokens .DimensionToken , tokens .NumberToken )
6066 ), f"Unexpected node type { c .type } "
61- return isinstance (c , (tokens .DimensionToken , tokens .NumberToken ))
67+ if isinstance (c , (tokens .DimensionToken , tokens .NumberToken )):
68+ return True
69+
70+ return False
6271
6372
6473def find_shadow (rules ):
@@ -140,8 +149,14 @@ def test_skip_whitespace(self):
140149 def test_has_shadow (self ):
141150 for expected , css in [
142151 (True , "html {box-shadow: 10px 5px 5px red;}" ),
152+ (True , "html {text-shadow: 1px 1px 2px pink;}" ),
153+ (True , "html {text-shadow: 5px 5px #558ABB;}" ),
143154 (False , "html {box-shadow: none;}" ),
155+ (False , "html {text-shadow: none;}" ),
156+ (True , "html {text-shadow: 5px 5px #558ABB; box-shadow: none;}" ),
157+ (True , "html {text-shadow: none; box-shadow: 10px 5px 5px red;}" ),
144158 (False , "html {}" ),
159+ (False , "html {color: red; font-weight: bold;}" ),
145160 ]:
146161 with self .subTest (css = css , expected = expected ):
147162 (rule ,) = parse_stylesheet (css )
@@ -190,6 +205,7 @@ def test_selector_str_pseudoclass_nonstandard(self):
190205// fit well with our design.
191206@mixin noshadow {
192207 box-shadow: none;
208+ text-shadow: none;
193209 border-radius: unset;
194210}
195211"""
0 commit comments