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

Projects
None yet
4 participants
@koba04
Copy link
Contributor

commented Jan 30, 2016

Fixed #5853

@koba04 koba04 force-pushed the koba04:add-warning-for-adding-synthetic-event-property branch from 1b00af6 to 4e6ceb4 Jan 30, 2016

@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

This comment has been minimized.

Copy link

commented Jan 30, 2016

@koba04 updated the pull request.

@koba04

This comment has been minimized.

Copy link
Contributor Author

commented Jan 31, 2016

should I reimplement this using Proxy?

@koba04 koba04 referenced this pull request Feb 2, 2016

Closed

Seal pooled events? #5853

@jimfb

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link
Contributor Author

commented Feb 2, 2016

Thanks!

the stack trace more useful.

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

@jimfb

This comment has been minimized.

Copy link
Contributor

commented Feb 11, 2016

Ping @koba04

@koba04

This comment has been minimized.

Copy link
Contributor Author

commented Feb 11, 2016

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

@facebook-github-bot

This comment has been minimized.

Copy link

commented Feb 12, 2016

@koba04 updated the pull request.

@koba04 koba04 force-pushed the koba04:add-warning-for-adding-synthetic-event-property branch from b8b6f33 to 7dd1986 Feb 12, 2016

@facebook-github-bot

This comment has been minimized.

Copy link

commented Feb 12, 2016

@koba04 updated the pull request.

@koba04

This comment has been minimized.

Copy link
Contributor Author

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 = [

This comment has been minimized.

Copy link
@jimfb

jimfb Feb 18, 2016

Contributor

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.

@@ -17,6 +17,19 @@ var assign = require('Object.assign');
var emptyFunction = require('emptyFunction');
var warning = require('warning');

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

This comment has been minimized.

Copy link
@jimfb

jimfb Feb 18, 2016

Contributor

A better name would be isProxySupported.

@jimfb

This comment has been minimized.

Copy link
Contributor

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 koba04:add-warning-for-adding-synthetic-event-property branch from 7dd1986 to decff26 Feb 18, 2016

apply: function(constructor, that, args) {
return new Proxy(constructor.apply(that, args), {
set: function(target, prop, value) {
if (prop !== 'isPersistent' &&

This comment has been minimized.

Copy link
@koba04

koba04 Feb 18, 2016

Author Contributor

this condition is for event.persist()

@facebook-github-bot

This comment has been minimized.

Copy link

commented Feb 18, 2016

@koba04 updated the pull request.

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

This comment has been minimized.

Copy link
@koba04

koba04 Feb 18, 2016

Author Contributor

this is to avoid a warning in the persistent event.

@koba04

This comment has been minimized.

Copy link
Contributor Author

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

This comment has been minimized.

Copy link

commented Feb 19, 2016

@koba04 updated the pull request.

1 similar comment
@facebook-github-bot

This comment has been minimized.

Copy link

commented Feb 24, 2016

@koba04 updated the pull request.

@jimfb

This comment has been minimized.

Copy link
Contributor

commented Feb 24, 2016

Thanks @koba04!

jimfb added a commit that referenced this pull request Feb 24, 2016

Merge pull request #5947 from koba04/add-warning-for-adding-synthetic…
…-event-property

Add a warning for adding a property in the SyntheticEvent object

@jimfb jimfb merged commit dff05be into facebook:master Feb 24, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@koba04

This comment has been minimized.

Copy link
Contributor Author

commented Feb 25, 2016

Thank you!!

@koba04 koba04 deleted the koba04:add-warning-for-adding-synthetic-event-property branch Feb 25, 2016

koba04 added a commit to koba04/react that referenced this pull request Mar 9, 2016

alunyov pushed a commit to alunyov/react that referenced this pull request Mar 10, 2016

edvinerikson pushed a commit to edvinerikson/react that referenced this pull request Mar 11, 2016

@renovate renovate bot referenced this pull request Feb 2, 2018

Open

Update dependency react to v0.14.9 #29

0 of 1 task complete

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

Fix isDefaultPrevented and isPropagationStopped to not get nulled
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

Remove the use of proxies for synthetic events in DEV (#13225)
* 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

This comment has been minimized.

Copy link
Member

commented Jul 17, 2018

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

TejasQ added a commit to TejasQ/react that referenced this pull request Aug 26, 2018

Remove the use of proxies for synthetic events in DEV (facebook#13225)
* Revert facebook#5947 and disable the test

* Fix isDefaultPrevented and isPropagationStopped to not get nulled

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

* Add a comment

* Run Prettier

* Fix grammar

iyegoroff added a commit to iyegoroff/react that referenced this pull request Mar 9, 2019

Remove the use of proxies for synthetic events in DEV (facebook#13225)
* Revert facebook#5947 and disable the test

* Fix isDefaultPrevented and isPropagationStopped to not get nulled

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

* Add a comment

* Run Prettier

* Fix grammar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.