Skip to content
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

Playwright compatibility: Improve valueFromRemoteObject null detection #1369

Merged
merged 1 commit into from
Jun 5, 2024

Conversation

inancgumus
Copy link
Member

@inancgumus inancgumus commented Jun 5, 2024

What?

Improve valueFromRemoteObject null detection by returning a Go nil instead of "null" as a string.

Why?

Previously, we couldn't detect a null value:

v, _ := page.GetAttribute("#el", "missing", nil)
assert.Nil(t, nil, v) // v is not nil. it's "null"

After this PR, v will be nil instead of "null" as a string. This enables us to detect nil in methods like GetAttribute, TextNode, etc., to tell the user that what they're looking for does not exist instead of returning "null" or an empty string.

Checklist

  • I have performed a self-review of my code
  • I have added tests for my changes
  • I have commented on my code, particularly in hard-to-understand areas

@inancgumus inancgumus added the enhancement New feature or request label Jun 5, 2024
@inancgumus inancgumus self-assigned this Jun 5, 2024
@inancgumus inancgumus force-pushed the fix/valueFromRemoteObject-for-null branch from 3025d90 to ca059a1 Compare June 5, 2024 14:21
Previously, we can't detect a null value:

        v, _ := page.GetAttribute("#el", "missing", nil)
        assert.Nil(t, nil, v) // v is not nil

Now, `v` will be `nil` instead of "null" as a string. This enables us to
detect `nil` in methods like GetAttribute, TextNode, etc. to tell the
user that what they're looking for does not exist instead of returning
"null" or an empty string.
@inancgumus inancgumus force-pushed the fix/valueFromRemoteObject-for-null branch from ca059a1 to d6e3ca8 Compare June 5, 2024 14:21
@inancgumus inancgumus marked this pull request as ready for review June 5, 2024 14:26
@inancgumus inancgumus requested a review from ankur22 June 5, 2024 14:26
Copy link
Collaborator

@ankur22 ankur22 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't fault the logic. Thanks for fixing this!

@inancgumus inancgumus merged commit b1b6e9e into async/frame Jun 5, 2024
14 checks passed
@inancgumus inancgumus deleted the fix/valueFromRemoteObject-for-null branch June 5, 2024 14:54
@inancgumus inancgumus mentioned this pull request Jun 5, 2024
3 tasks
@inancgumus inancgumus changed the title Improve valueFromRemoteObject null detection Playwright compatibility: Improve valueFromRemoteObject null detection Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants