@@ -49,16 +49,25 @@ def skip_whitespace(nodes):
49
49
return filter (lambda node : node .type != "whitespace" , nodes )
50
50
51
51
52
+ SHADOW_CSS_PROPERTIES = {
53
+ 'box-shadow' ,
54
+ 'text-shadow' ,
55
+ }
56
+
57
+
52
58
def has_shadow (rule ):
53
59
if not rule .content :
54
60
return False
55
61
56
62
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 :
58
64
assert isinstance (
59
65
c , (tokens .IdentToken , tokens .DimensionToken , tokens .NumberToken )
60
66
), 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
62
71
63
72
64
73
def find_shadow (rules ):
@@ -140,8 +149,14 @@ def test_skip_whitespace(self):
140
149
def test_has_shadow (self ):
141
150
for expected , css in [
142
151
(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;}" ),
143
154
(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;}" ),
144
158
(False , "html {}" ),
159
+ (False , "html {color: red; font-weight: bold;}" )
145
160
]:
146
161
with self .subTest (css = css , expected = expected ):
147
162
(rule ,) = parse_stylesheet (css )
@@ -190,6 +205,7 @@ def test_selector_str_pseudoclass_nonstandard(self):
190
205
// fit well with our design.
191
206
@mixin noshadow {
192
207
box-shadow: none;
208
+ text-shadow: none;
193
209
border-radius: unset;
194
210
}
195
211
"""
0 commit comments