summaryrefslogtreecommitdiff
path: root/htmtl/parsers/when.py
blob: 57a965aab82b854f5c0d18843bc6696dca4121bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
from typing import Optional
from dompa.nodes import Node
from ..parser import Parser


class When(Parser):
    def traverse(self, node: Node) -> Optional[Node]:
        if "when" in node.attributes:
            if not self.expression(node.attributes["when"]):
                return None

            node.attributes.pop("when")

        return node