Skip to content

Commit aa141bc

Browse files
committed
keep selectors that we can't parse, to be safe
1 parent d21b4a3 commit aa141bc

File tree

4 files changed

+28
-2
lines changed

4 files changed

+28
-2
lines changed

mincss/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.10.0'
1+
__version__ = '0.11.0'

mincss/processor.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,9 +495,11 @@ def _selector_query_found(self, bodies, selector):
495495
except SelectorSyntaxError:
496496
print('TROUBLEMAKER', file=sys.stderr)
497497
print(repr(selector), file=sys.stderr)
498+
return True # better be safe and let's keep it
498499
except ExpressionError:
499500
print('EXPRESSIONERROR', file=sys.stderr)
500501
print(repr(selector), file=sys.stderr)
502+
return True # better be safe and let's keep it
501503
return False
502504

503505
@staticmethod

tests/complex-selector.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset='utf-8'>
5+
<title>test page</title>
6+
<style>
7+
a[href^="javascript:"] { color: pink; }
8+
a[href^="javascript:"]:after { content: "x"; }
9+
</style>
10+
</head>
11+
<body>
12+
<h1>h1</h1>
13+
<a href="javascript:alert('hi')">actually</a>
14+
15+
</body>
16+
</html>

tests/test_mincss.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,6 @@ def test_nth_child(self):
320320
url = 'file://' + html
321321
p = Processor()
322322
p.process(url)
323-
# print repr(p.inlines[0].before)
324323
after = p.inlines[0].after
325324
# These mouse related one should stay, even though they're
326325
# currently NOT being acted upon with some input device.
@@ -334,3 +333,12 @@ def test_nth_child(self):
334333
ok_('div > :last-child { color: brown; }' in after)
335334
ok_('div > :not(p) { color: blue; }' in after)
336335
ok_('div > :nth-child(2) { color: red; }' in after)
336+
337+
def test_complex_colons_in_selector_expression(self):
338+
html = os.path.join(HERE, 'complex-selector.html')
339+
url = 'file://' + html
340+
p = Processor()
341+
p.process(url)
342+
after = p.inlines[0].after
343+
ok_('a[href^="javascript:"] { color: pink; }' in after)
344+
ok_('a[href^="javascript:"]:after { content: "x"; }' in after)

0 commit comments

Comments
 (0)