shithub: mycel

Download patch

ref: 833decef052e263ed371d55774d4598e1bd17016
parent: 4c8c0104cf491d9d9ccdc9f7d020507fe37c26bd
author: Philip Silva <philip.silva@protonmail.com>
date: Thu Jan 21 15:43:08 EST 2021

unify generic tag handling

--- a/browser/browser.go
+++ b/browser/browser.go
@@ -884,30 +884,6 @@
 			}
 		case "table":
 			return NewTable(n).Element(r+1, b, n)
-		case "noscript":
-			if *ExperimentalJsInsecure || !*EnableNoScriptTag {
-				return nil
-			}
-			fallthrough
-		case "body", "p", "h1", "center", "nav", "article", "header", "div", "td":
-			var innerContent duit.UI
-			if nodes.IsPureTextContent(*n) {
-				t := strings.TrimSpace(nodes.ContentFrom(*n))
-				innerContent = &ColoredLabel{
-					Label: &duit.Label{
-						Text: t,
-						Font: n.Font(),
-					},
-					n: n,
-				}
-			} else {
-				innerContent = InnerNodesToBox(r+1, b, n)
-			}
-
-			return NewBoxElement(
-				innerContent,
-				n,
-			)
 		case "img", "svg":
 			return NewElement(
 				NewImage(n),
@@ -969,9 +945,31 @@
 			)
 			el.makeLink(href)
 			return el
+		case "noscript":
+			if *ExperimentalJsInsecure || !*EnableNoScriptTag {
+				return nil
+			}
+			fallthrough
 		default:
 			// Internal node object
-			return InnerNodesToBox(r+1, b, n)
+			var innerContent duit.UI
+			if nodes.IsPureTextContent(*n) {
+				t := strings.TrimSpace(nodes.ContentFrom(*n))
+				innerContent = &ColoredLabel{
+					Label: &duit.Label{
+						Text: t,
+						Font: n.Font(),
+					},
+					n: n,
+				}
+			} else {
+				innerContent = InnerNodesToBox(r+1, b, n)
+			}
+
+			return NewBoxElement(
+				innerContent,
+				n,
+			)
 		}
 	} else if n.Type() == html.TextNode {
 		// Leaf text object