Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,23 @@
- Support time inputs [#245]
- Add initial support for shadow_root [#234]
- Support `Capybara::Cuprite::Node#rect` [#276]
- Extend `Node#set` with the `datetime-local` input type [#295]
- Support HTML5 drag-and-drop and drag modifier keys in `Node#drag_to` [#315]
- Support `Element#drop` for files and strings [#316]

### Changed
- Bump Ferrum dependency to `~> 0.18.0`

### Fixed
- Ensure node has focus before setting value [#280]
- Ensure the node has focus before setting value [#280]
- Raise `ObsoleteNode` instead of silently acting on a node that got disconnected from the DOM between being found and being used [#239]
- `Capybara::Cuprite::Node#send_keys` ignores empty or nil keys instead of raising, matching the Selenium and rack_test drivers [#313]
- `Driver#switch_to_frame` accepts a `Capybara::Cuprite::Node` instead of only a wrapped `Capybara::Node::Element` [#312]
- Report `tag_name` as `"ShadowRoot"` for shadow root nodes [#318]
- Treat non-summary descendants of a closed `<details>` element as non-visible [#317]
- `switch_to_window` sends `Target.activateTarget` so Chrome reactivates the window's renderer immediately instead of leaving it backgrounded, which could stall the next input command for several seconds [#321]
- `Node#set` fires `input` and `change` events for a `color` input, since its value can only be set via JavaScript and never gets them naturally [#229]
- Generate a `FocusEvent` (not a generic `Event`) for focus-related events (`blur`, `focus`, `focusin`, `focusout`), matching real browser behavior [#272]

### Removed

Expand Down
2 changes: 1 addition & 1 deletion lib/capybara/cuprite/javascripts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ class Cuprite {
options["button"] || 0, null
)
} else if (EVENTS.FOCUS.indexOf(name) != -1) {
event = this.obtainEvent(name);
event = new FocusEvent(name, { bubbles: true, cancelable: true });
} else if (EVENTS.FORM.indexOf(name) != -1) {
event = this.obtainEvent(name);
} else {
Expand Down
4 changes: 2 additions & 2 deletions spec/features/session_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,11 @@
end

it "fires the focus event" do
expect(@session.find(:css, "#changes_on_focus").text).to eq("Focus")
expect(@session.find(:css, "#changes_on_focus").text).to eq("Focus (FocusEvent)")
end

it "fires the blur event" do
expect(@session.find(:css, "#changes_on_blur").text).to eq("Blur")
expect(@session.find(:css, "#changes_on_blur").text).to eq("Blur (FocusEvent)")
end

it "fires the keydown event before the value is updated" do
Expand Down
6 changes: 3 additions & 3 deletions spec/support/public/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ $(function() {
$("#changes_on_keypress").text(increment)
})
.focus(function(event) {
$("#changes_on_focus").text("Focus")
$("#changes_on_focus").text(`Focus (${event.originalEvent.constructor.name})`)

@davidrunger davidrunger Aug 26, 2024

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I would like tests to cover the change in this PR, so I added the event constructor name in parentheses here. On main, this text would be Focus (Event). On this branch, it's Focus (FocusEvent).

})
.blur(function() {
$("#changes_on_blur").text("Blur")
.blur(function(event) {
$("#changes_on_blur").text(`Blur (${event.originalEvent.constructor.name})`)
})

$("#change_me_color")
Expand Down
Loading