Fixing SetAttributes

This commit is contained in:
Randy Cahyana 2017-02-16 16:37:39 +07:00
parent b5032069e3
commit 6c5096f06a

View File

@ -7,6 +7,7 @@ import (
"fmt" "fmt"
"image" "image"
"image/png" "image/png"
"strconv"
"strings" "strings"
"sync" "sync"
@ -219,11 +220,11 @@ func SetAttributes(sel interface{}, attributes map[string]string, opts ...QueryO
return errors.New("expected at least one element") return errors.New("expected at least one element")
} }
attrs := make([]string, len(attributes)*2) attrs := make([]string, len(attributes))
i := 0 i := 0
for k, v := range attributes { for k, v := range attributes {
attrs[i], attrs[i+1] = k, v attrs[i] = fmt.Sprintf(`%s=%s`, k, strconv.Quote(v))
i += 2 i++
} }
return dom.SetAttributesAsText(nodes[0].NodeID, strings.Join(attrs, " ")).Do(ctxt, h) return dom.SetAttributesAsText(nodes[0].NodeID, strings.Join(attrs, " ")).Do(ctxt, h)