Skip to content

Conversation

@AndersDJohnson
Copy link

Needed this to emulate native user-driven 'change' event on input elements, at least in Chrome 28, where jQuery's .change() and .trigger('change') failed me.

@mikesherov
Copy link
Member

I know this is very old at this point, but thanks for contributing! Would you be able to add some unit tests for this change?

@AndersDJohnson
Copy link
Author

Sure - basic unit test added to prove it fires, at least in my browser (Chrome 36.0.1985.143 m, Windows). As for other browsers, I am not sure.

How do you do cross-browser testing? I see some possible jQuery TestSwarm integration, but I'm not sure.

Though it seems to work for now, apparently change is not technically a UIEvent but a generic Event per DOM Level 2 via MDN Event reference. So we could have a generic Event implementation as well, and move change to it instead.

Did you mean this pull request is old, or the project is old?

@mikesherov
Copy link
Member

I meant the pull request; Not your fault, mine. Thanks for adding the tests. I'll do some cross browser testing.

@brian-mann
Copy link

When will this get merged in? Is it ready to go?

Also, cancelable should be false, not true, as per the spec.

https://developer.mozilla.org/en-US/docs/Web/Events/change

@AndersDJohnson
Copy link
Author

@brian-mann Are you asking me or @mikesherov? From my end it worked in Chrome 28-36 when I made the PR, but wasn't tested across various browsers.

Per my earlier comment, I still think it shouldn't be a UIEvent - I can try correct if there is interest.

@brian-mann
Copy link

I'm asking @mikesherov since he said he was doing some cross browser testing.

And yes, I believe the event should be HTMLEvents not UIEvent. This is a Dom Level 0 event.

@AndersDJohnson
Copy link
Author

@brian-mann In order to correct cancelable and UIEvent->Event, I think this warrants some refactoring.

@AndersDJohnson
Copy link
Author

@brian-mann I've just pushed some changes in c6a417d that address the above problems (change is now cancelable and HTMLEvents instead of UIEvents).

@AndersDJohnson AndersDJohnson force-pushed the master branch 2 times, most recently from 38a11d1 to c737641 Compare November 11, 2014 02:23
@mikesherov
Copy link
Member

These changes look good, I've just been swamped with other work, and I missed the notifications earlier.

Some of this is a bit over my head, can you give me a short explanation of what firing advantages fire HTMLEvents has over what simulate is currently capable of?

@AndersDJohnson
Copy link
Author

@mikesherov There are different kinds of browser events with different APIs. Currently this library supports key (KeyboardEvent) and mouse (MouseEvent) events only, not HTMLEvents such as change. To create these events correctly in a programmatic fashion, we need to add mappings from the event name strings to the correct event type interface.

See:

@jzaefferer
Copy link
Member

Thank you for the contribution. As you've probably guessed already, this project isn't well maintained. I've added some details about that here: https://github.com/jquery/jquery-simulate#project-status

Base automatically changed from master to main March 16, 2021 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants