Skip to content

Commit

Permalink
Internally refer to "has" selectors as "relative" selectors.
Browse files Browse the repository at this point in the history
  • Loading branch information
facelessuser committed Jan 1, 2019
1 parent 3954c29 commit e149833
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions soupsieve/css_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
# Parse flags
FLG_PSEUDO = 0x01
FLG_NOT = 0x02
FLG_HAS = 0x04
FLG_RELATIVE = 0x04
FLG_DEFAULT = 0x08
FLG_HTML = 0x10
FLG_INDETERMINATE = 0x20
Expand Down Expand Up @@ -533,7 +533,7 @@ def parse_pseudo_open(self, sel, name, has_selector, iselector, index):
if name == ':not':
flags |= FLG_NOT
if name == ':has':
flags |= FLG_HAS
flags |= FLG_RELATIVE

sel.selectors.append(self.parse_selectors(iselector, index, flags))
has_selector = True
Expand Down Expand Up @@ -655,7 +655,7 @@ def parse_selectors(self, iselector, index=0, flags=0):
split_last = False
is_open = flags & FLG_OPEN
is_pseudo = flags & FLG_PSEUDO
is_has = flags & FLG_HAS
is_relative = flags & FLG_RELATIVE
is_not = flags & FLG_NOT
is_html = flags & FLG_HTML
is_default = flags & FLG_DEFAULT
Expand All @@ -666,8 +666,8 @@ def parse_selectors(self, iselector, index=0, flags=0):
print(' is_pseudo: True')
if is_open:
print(' is_open: True')
if is_has:
print(' is_has: True')
if is_relative:
print(' is_relative: True')
if is_not:
print(' is_not: True')
if is_html:
Expand All @@ -677,7 +677,7 @@ def parse_selectors(self, iselector, index=0, flags=0):
if is_indeterminate:
print(' is_indeterminate: True')

if is_has:
if is_relative:
selectors.append(_Selector())

try:
Expand Down Expand Up @@ -712,7 +712,7 @@ def parse_selectors(self, iselector, index=0, flags=0):
elif key == 'combine':
if split_last:
raise SyntaxError("Unexpected combining character at position {}".format(m.start(0)))
if is_has:
if is_relative:
has_selector, sel, rel_type = self.parse_has_split(
sel, m, has_selector, selectors, rel_type
)
Expand Down Expand Up @@ -744,14 +744,14 @@ def parse_selectors(self, iselector, index=0, flags=0):
if not sel.tag and not is_pseudo:
# Implied `*`
sel.tag = ct.SelectorTag('*', None)
if is_has:
if is_relative:
sel.rel_type = rel_type
selectors[-1].relations.append(sel)
else:
sel.relations.extend(relations)
del relations[:]
selectors.append(sel)
elif is_has:
elif is_relative:
# We will always need to finish a selector when `:has()` is used as it leads with combining.
raise SyntaxError('Missing selectors after combining type.')

Expand Down

0 comments on commit e149833

Please sign in to comment.