From c6bee9e690f959fce4e175ebda4f756fead3023d Mon Sep 17 00:00:00 2001 From: Enguerrand ARMINJON MacBook Pro 13p Date: Thu, 9 Dec 2021 13:57:17 +0100 Subject: [PATCH] Disable click effect and decoration when a tag have no href attribute --- lib/src/interactable_element.dart | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/lib/src/interactable_element.dart b/lib/src/interactable_element.dart index 504f185406..2aab878a64 100644 --- a/lib/src/interactable_element.dart +++ b/lib/src/interactable_element.dart @@ -22,20 +22,30 @@ enum Gesture { TAP, } -InteractableElement parseInteractableElement( +StyledElement parseInteractableElement( dom.Element element, List children) { switch (element.localName) { case "a": - return InteractableElement( + if (element.attributes.containsKey('href')) { + return InteractableElement( + name: element.localName!, + children: children, + href: element.attributes['href'], + style: Style( + color: Colors.blue, + textDecoration: TextDecoration.underline, + ), + node: element, + elementId: element.id + ); + } + // When tag have no href, it must be non clickable and without decoration. + return StyledElement( name: element.localName!, children: children, - href: element.attributes['href'], - style: Style( - color: Colors.blue, - textDecoration: TextDecoration.underline, - ), + style: Style(), node: element, - elementId: element.id + elementId: element.id, ); /// will never be called, just to suppress missing return warning default: @@ -48,4 +58,4 @@ InteractableElement parseInteractableElement( elementId: "[[No ID]]" ); } -} \ No newline at end of file +}