Browse Source

html: add missing special elements for <svg> and <math>

See: https://html.spec.whatwg.org/multipage/parsing.html#special

Change-Id: Ief3f0c04d2c7530a44221cb8fa2e22dd6d8b8427
Reviewed-on: https://go-review.googlesource.com/136876
Reviewed-by: Nigel Tao <nigeltao@golang.org>
Kunpei Sakai 7 years ago
parent
commit
f04abc6bdf
1 changed files with 9 additions and 1 deletions
  1. 9 1
      html/const.go

+ 9 - 1
html/const.go

@@ -97,8 +97,16 @@ func isSpecialElement(element *Node) bool {
 	switch element.Namespace {
 	switch element.Namespace {
 	case "", "html":
 	case "", "html":
 		return isSpecialElementMap[element.Data]
 		return isSpecialElementMap[element.Data]
+	case "math":
+		switch element.Data {
+		case "mi", "mo", "mn", "ms", "mtext", "annotation-xml":
+			return true
+		}
 	case "svg":
 	case "svg":
-		return element.Data == "foreignObject"
+		switch element.Data {
+		case "foreignObject", "desc", "title":
+			return true
+		}
 	}
 	}
 	return false
 	return false
 }
 }