Returns True if the given element matches the simple CSS selector.
(self, e)
| 2914 | return e |
| 2915 | |
| 2916 | def match(self, e): |
| 2917 | """ Returns True if the given element matches the simple CSS selector. |
| 2918 | """ |
| 2919 | if not isinstance(e, Element): |
| 2920 | return False |
| 2921 | if self.tag not in (e.tag, "*"): |
| 2922 | return False |
| 2923 | if self.id not in (e.id.lower(), "", None): |
| 2924 | return False |
| 2925 | if self.classes.issubset(set(map(str.lower, e.attr.get("class", "").split()))) is False: |
| 2926 | return False |
| 2927 | if "first-child" in self.pseudo and self._first_child(e.parent) != e: |
| 2928 | return False |
| 2929 | for k, v in self.attributes: |
| 2930 | if k not in e.attrs or v not in (e.attrs[k].lower(), True): |
| 2931 | return False |
| 2932 | return True |
| 2933 | |
| 2934 | def search(self, e): |
| 2935 | """ Returns the nested elements that match the simple CSS selector. |
no test coverage detected