-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prepare Page
for async migration part #2
#1345
Conversation
163eec3
to
944e00b
Compare
944e00b
to
ab24cee
Compare
ab24cee
to
1181a75
Compare
@@ -948,21 +948,19 @@ func (f *Frame) FrameElement() (*ElementHandle, error) { | |||
} | |||
|
|||
// GetAttribute of the first element found that matches the selector. | |||
func (f *Frame) GetAttribute(selector, name string, opts goja.Value) any { | |||
func (f *Frame) GetAttribute(selector, name string, opts goja.Value) (any, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GetAttribute
should only returns a string
. Having taken a quick look at the call stack it looks like we're using element.getAttribute, maybe a string
instead of any
?
It should also map to nil
if the string is empty... not sure what the best way forward for that would be since an attribute could just be empty :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about returning a bool
to detect that in the mapping layer?
func (f *Frame) GetAttribute(selector, name string, opts goja.Value) (string, bool, error)
Even so, this should better go to a new issue because it'd change the existing signatures. I've tried to keep the signatures intact other than adding errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Love seeing those panics being replaced by errors ❤️
What?
Turns panics into errors only for
Page
's first set of methods. The rest will be in another PR.Why?
To make the async migration more reliable.
Checklist
Related PR(s)/Issue(s)
#1307