From cf82003f7e25c5a30df6eef7d4707c7fb3ae2692 Mon Sep 17 00:00:00 2001 From: Martin Angers Date: Fri, 25 Apr 2014 15:28:38 -0400 Subject: [PATCH] add test to detect a   from a call to Text() --- property_test.go | 13 +++++++++++++ traversal.go | 2 -- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/property_test.go b/property_test.go index 2dd52b4..d6355a4 100644 --- a/property_test.go +++ b/property_test.go @@ -61,3 +61,16 @@ func TestHtml(t *testing.T) { } } } + +func TestNbsp(t *testing.T) { + src := `

Some text

` + d, err := NewDocumentFromReader(strings.NewReader(src)) + if err != nil { + t.Fatal(err) + } + txt := d.Find("p").Text() + ix := strings.Index(txt, "\u00a0") + if ix != 4 { + t.Errorf("expected a non-breaking space at index 4, got %d", ix) + } +} diff --git a/traversal.go b/traversal.go index f8d919e..8fbeddf 100644 --- a/traversal.go +++ b/traversal.go @@ -492,8 +492,6 @@ func getChildrenWithSiblingType(parent *html.Node, st siblingType, skipNode *htm // Not a valid node, try again from this one cur = ret } - // For Go 1.0 compatibility - panic("Unreachable code reached.") } for c := iter(nil); c != nil; c = iter(c) {