Skip to content

Commit 6de34b9

Browse files
authored
Merge pull request Sub6Resources#934 from EA-YOUHOU/Fix/a-tag-no-href
Disable click effect and decoration when a tag have no href attribute
2 parents e550c99 + c6bee9e commit 6de34b9

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

lib/src/interactable_element.dart

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,30 @@ enum Gesture {
2222
TAP,
2323
}
2424

25-
InteractableElement parseInteractableElement(
25+
StyledElement parseInteractableElement(
2626
dom.Element element, List<StyledElement> children) {
2727
switch (element.localName) {
2828
case "a":
29-
return InteractableElement(
29+
if (element.attributes.containsKey('href')) {
30+
return InteractableElement(
31+
name: element.localName!,
32+
children: children,
33+
href: element.attributes['href'],
34+
style: Style(
35+
color: Colors.blue,
36+
textDecoration: TextDecoration.underline,
37+
),
38+
node: element,
39+
elementId: element.id
40+
);
41+
}
42+
// When <a> tag have no href, it must be non clickable and without decoration.
43+
return StyledElement(
3044
name: element.localName!,
3145
children: children,
32-
href: element.attributes['href'],
33-
style: Style(
34-
color: Colors.blue,
35-
textDecoration: TextDecoration.underline,
36-
),
46+
style: Style(),
3747
node: element,
38-
elementId: element.id
48+
elementId: element.id,
3949
);
4050
/// will never be called, just to suppress missing return warning
4151
default:
@@ -48,4 +58,4 @@ InteractableElement parseInteractableElement(
4858
elementId: "[[No ID]]"
4959
);
5060
}
51-
}
61+
}

0 commit comments

Comments
 (0)