mirror of
https://github.com/PuerkitoBio/goquery
synced 2025-10-23 08:19:56 +08:00
make AttrOr return default value if selection is empty
This commit is contained in:
@@ -20,6 +20,11 @@ func TestAttrOr(t *testing.T) {
|
||||
} else {
|
||||
t.Logf("Value returned for not existing attribute: %v.", val)
|
||||
}
|
||||
if val := Doc().Find("zz").AttrOr("fake-attribute", "alternative"); val != "alternative" {
|
||||
t.Error("Expected an alternative value for 'fake-attribute' on an empty selection.")
|
||||
} else {
|
||||
t.Logf("Value returned for empty selection: %v.", val)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAttrNotExist(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user