def matches(self, tag, id, classes):
        """ Given an id and a list of classes, return True if this selector would match.
        """
        element = self.elements[0]
        unmatched_ids = [name[1:] for name in element.names if name.startswith('#')]
        unmatched_classes = [name[1:] for name in element.names if name.startswith('.')]
        unmatched_tags = [name for name in element.names if name is not '*' and not name.startswith('#') and not name.startswith('.')]
        
        if tag and tag in unmatched_tags:
            unmatched_tags.remove(tag)

        if id and id in unmatched_ids:
            unmatched_ids.remove(id)

        for class_ in classes:
            if class_ in unmatched_classes:
                unmatched_classes.remove(class_)
        
        if unmatched_tags or unmatched_ids or unmatched_classes:
            return False

        else:
            return True
def matches ( self , tag , id , classes ) : element = self . elements [ 0 ] unmatched_ids = [ name [ 1 : ] for name in element . names if name . startswith ( '#' ) ] unmatched_classes = [ name [ 1 : ] for name in element . names if name . startswith ( '.' ) ] unmatched_tags = [ name for name in element . names if name is not '*' and not name . startswith ( '#' ) and not name . startswith ( '.' ) ] if tag and tag in unmatched_tags : unmatched_tags . remove ( tag ) if id and id in unmatched_ids : unmatched_ids . remove ( id ) for class_ in classes : if class_ in unmatched_classes : unmatched_classes . remove ( class_ ) if unmatched_tags or unmatched_ids or unmatched_classes : return False else : return True
Given an id and a list of classes, return True if this selector would match.