Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upcorrectly handle the fact that nodeName is uppercase #251
Conversation
This comment has been minimized.
This comment has been minimized.
@dmitshur thank you for reporting! I missed the fact that |
This comment has been minimized.
This comment has been minimized.
Ah, this actually appears to be an incorrect limitation of |
This comment has been minimized.
This comment has been minimized.
codecov-io
commented
Dec 1, 2019
Codecov Report
@@ Coverage Diff @@
## master #251 +/- ##
==========================================
+ Coverage 59.31% 59.43% +0.12%
==========================================
Files 4 4
Lines 671 673 +2
==========================================
+ Hits 398 400 +2
Misses 215 215
Partials 58 58
Continue to review full report at Codecov.
|
// We must call the prototype method here to workaround a limitation of | ||
// syscall/js in both Go and GopherJS where we cannot call the | ||
// `toLowerCase` string method. See https://github.com/golang/go/issues/35917 | ||
return js.Global().Get("String").Get("prototype").Get("toLowerCase").Call("call", js.ValueOf(s)).String() |
This comment has been minimized.
This comment has been minimized.
dmitshur
Dec 1, 2019
Member
Do you have a way of checking whether performance is impacted doing this on each toLower
call, compared to:
func toLower(s string) string {
return toLowerCase.Call("call", js.ValueOf(s)).String()
}
var toLowerCase = js.Global().Get("String").Get("prototype").Get("toLowerCase")
Also, the string -> js.Value -> string
conversions can be short-circuited if you're willing to create a more dedicated helper for getting the node name, for example:
// +build js
func lowerNodeName(node jsObject) string {
return toLowerCase.Call("call", node.Get("nodeName")).String()
}
// +build !js
func lowerNodeName(node jsObject) string {
return strings.ToLower(node.Get("nodeName").String())
}
I don't have a sense whether the performance difference would be significant or negligible.
If performance isn't a bottneck or priority for now, this can all be considered later of course.
This comment has been minimized.
This comment has been minimized.
slimsag
Dec 1, 2019
Author
Member
I think even if performance of this is poor, it would probably be negligible AND since it only occurs on calls to RenderBody
, RenderInto
, RenderIntoNode
it is not very frequently called, so as-is is probably fine for now.
Benchmarking things overall (all of Vecty) would definitely be a good idea, though that will probably come a bit later.
slimsag commentedDec 1, 2019
Fixes issue reported by @dmitshur in https://github.com/gopherjs/vecty/pull/249/files#r352319035