summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS.txt2
-rw-r--r--bs4/element.py14
2 files changed, 9 insertions, 7 deletions
diff --git a/NEWS.txt b/NEWS.txt
index 1908db0..c65058c 100644
--- a/NEWS.txt
+++ b/NEWS.txt
@@ -6,7 +6,7 @@
- Added support for the adjacent sibling combinator (+) and the
general sibling combinator (~). Tests by "liquider". [bug=1082144]
- - The combinators (*, >, +, and ~) can now combine with any supported
+ - The combinators (>, +, and ~) can now combine with any supported
selector, not just one that selects based on tag name.
- Added limited support for the "nth-of-type" pseudo-class. Code
diff --git a/bs4/element.py b/bs4/element.py
index 0be349d..e7f4af9 100644
--- a/bs4/element.py
+++ b/bs4/element.py
@@ -1184,16 +1184,18 @@ class Tag(PageElement):
yield current
current = current.next_element
- _selectors_that_consume_an_extra_token = ['>', '+', '~']
+ # CSS selector code
+
+ _selector_combinators = ['>', '+', '~']
_select_debug = False
def select(self, selector, _candidate_generator=None):
"""Perform a CSS selection operation on the current element."""
tokens = selector.split()
current_context = [self]
- if tokens[-1] in self._selectors_that_consume_an_extra_token:
+ if tokens[-1] in self._selector_combinators:
raise ValueError(
- 'Final selector "%s" is missing an argument.' % tokens[-1])
+ 'Final combinator "%s" is missing an argument.' % tokens[-1])
if self._select_debug:
print 'Running CSS selector "%s"' % selector
for index, token in enumerate(tokens):
@@ -1201,10 +1203,10 @@ class Tag(PageElement):
print ' Considering token "%s"' % token
recursive_candidate_generator = None
tag_name = None
- if tokens[index-1] in self._selectors_that_consume_an_extra_token:
- # This token was consumed by the previous selector. Skip it.
+ if tokens[index-1] in self._selector_combinators:
+ # This token was consumed by the previous combinator. Skip it.
if self._select_debug:
- print ' Token was consumed by the previous selector.'
+ print ' Token was consumed by the previous combinator.'
continue
# Each operation corresponds to a checker function, a rule
# for determining whether a candidate matches the