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

Add a warning for adding a property in the SyntheticEvent object #5947

Merged

Conversation

koba04
Copy link
Contributor

@koba04 koba04 commented Jan 30, 2016

Fixed #5853

@koba04 koba04 force-pushed the add-warning-for-adding-synthetic-event-property branch from 1b00af6 to 4e6ceb4 Compare January 30, 2016 14:38
@koba04 koba04 changed the title Added a warning for adding a property in the SyntheticEvent object Add a warning for adding a property in the SyntheticEvent object Jan 30, 2016
@facebook-github-bot
Copy link

@koba04 updated the pull request.

@koba04
Copy link
Contributor Author

koba04 commented Jan 31, 2016

should I reimplement this using Proxy?

@koba04 koba04 mentioned this pull request Feb 2, 2016
@jimfb
Copy link
Contributor

jimfb commented Feb 2, 2016

Yeah, let's use Proxy objects, since that will allow us to detect writes when they happen, rather than when the event is returned to the pool, which will make the stack trace more useful.

@koba04
Copy link
Contributor Author

koba04 commented Feb 2, 2016

Thanks!

the stack trace more useful.

Ah, that's make sense!
I reimplement this using Proxy.

@jimfb
Copy link
Contributor

jimfb commented Feb 11, 2016

Ping @koba04

@koba04
Copy link
Contributor Author

koba04 commented Feb 11, 2016

Sorry, I'll update this in a few days!

@facebook-github-bot
Copy link

@koba04 updated the pull request.

@koba04 koba04 force-pushed the add-warning-for-adding-synthetic-event-property branch from b8b6f33 to 7dd1986 Compare February 12, 2016 12:07
@facebook-github-bot
Copy link

@koba04 updated the pull request.

@koba04
Copy link
Contributor Author

koba04 commented Feb 14, 2016

@jimfb I updated this PR!
I created a proxy for the SyntheticEvent constructor with Proxy APIs construct and apply. It has some diffs for supporting a constructor call and a function call.

var didWarnForAddedNewProperty = false;
var isSupportedProxy = typeof Proxy === 'function';

var shouldBeReleasedProperties = [
Copy link
Contributor

Choose a reason for hiding this comment

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

I think all these are fine, just noting this to myself (or others) because it's a potential change in the behavior of this class, but I don't think it has any impact on the overall program behavior.

@jimfb
Copy link
Contributor

jimfb commented Feb 18, 2016

@koba04 This looks good to me. One minor nitpick (above), plus a rebase is needed to merge. Also, if you could squash these into a single commit (git rebase -i and git push -f), that would be great. Other than that, I think this is good-to-go.

@jimfb jimfb added this to the 0.15 milestone Feb 18, 2016
@jimfb jimfb self-assigned this Feb 18, 2016
@koba04 koba04 force-pushed the add-warning-for-adding-synthetic-event-property branch from 7dd1986 to decff26 Compare February 18, 2016 10:34
apply: function(constructor, that, args) {
return new Proxy(constructor.apply(that, args), {
set: function(target, prop, value) {
if (prop !== 'isPersistent' &&
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this condition is for event.persist()

@facebook-github-bot
Copy link

@koba04 updated the pull request.

!target.constructor.Interface.hasOwnProperty(prop) &&
shouldBeReleasedProperties.indexOf(prop) === -1) {
warning(
didWarnForAddedNewProperty || target.isPersistent(),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is to avoid a warning in the persistent event.

@koba04
Copy link
Contributor Author

koba04 commented Feb 18, 2016

@jimfb Thank you for your review! I've fixed it. Additionally, I added some changes related persistent event with comments.

@facebook-github-bot
Copy link

@koba04 updated the pull request.

1 similar comment
@facebook-github-bot
Copy link

@koba04 updated the pull request.

@jimfb
Copy link
Contributor

jimfb commented Feb 24, 2016

Thanks @koba04!

jimfb added a commit that referenced this pull request Feb 24, 2016
…-event-property

Add a warning for adding a property in the SyntheticEvent object
@jimfb jimfb merged commit dff05be into facebook:master Feb 24, 2016
@koba04
Copy link
Contributor Author

koba04 commented Feb 25, 2016

Thank you!!

@koba04 koba04 deleted the add-warning-for-adding-synthetic-event-property branch February 25, 2016 01:26
koba04 added a commit to koba04/react that referenced this pull request Mar 9, 2016
edvinerikson pushed a commit to edvinerikson/react that referenced this pull request Mar 11, 2016
gaearon added a commit to gaearon/react that referenced this pull request Jul 17, 2018
gaearon added a commit to gaearon/react that referenced this pull request Jul 17, 2018
This was a bug introduced by facebook#5947. It's very confusing that they become nulled while stopPropagation/preventDefault don't.
gaearon added a commit that referenced this pull request Jul 17, 2018
* Revert #5947 and disable the test

* Fix isDefaultPrevented and isPropagationStopped to not get nulled

This was a bug introduced by #5947. It's very confusing that they become nulled while stopPropagation/preventDefault don't.

* Add a comment

* Run Prettier

* Fix grammar
@gaearon
Copy link
Collaborator

gaearon commented Jul 17, 2018

Note for future reference: this was reverted in #13225.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants