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 unknown property warning for use of autofocus #6461

Merged
merged 1 commit into from
Sep 3, 2016

Conversation

hkal
Copy link
Contributor

@hkal hkal commented Apr 8, 2016

Resolves #3248

This PR also:

  • Resurrects property warnings when ReactDOMFeatureFlags.useCreateElement is on
  • Adds property validity event to debug tool

I wrote some tests for this work, but didn't notice any other __DEV__ specific warnings being tested. I can include them with this PR if they're wanted.

@facebook-github-bot
Copy link

@hkal updated the pull request.

@hkal
Copy link
Contributor Author

hkal commented Apr 11, 2016

Went ahead and added the test-case after seeing some other tests for __DEV__ only code paths.

@jimfb - noticed you set the label on the original bug. Let me know if this adequately addresses the problem.

@facebook-github-bot
Copy link

@hkal updated the pull request.

@gaearon
Copy link
Collaborator

gaearon commented Apr 11, 2016

Hmm. I think the plan was to move these warnings to element creation: #6345
cc @jimfb

@jimfb
Copy link
Contributor

jimfb commented Jun 29, 2016

@hkal Sorry for letting this one slip through the cracks. Can you rebase and move it to element creation like in #6345 and then I think this is ready to merge.

@hkal
Copy link
Contributor Author

hkal commented Jun 30, 2016

@jimfb - No worries.

Just so I'm clear, is the direction to consolidate onCreateMarkupForProperty, onSetValueForProperty, onDeleteValueForProperty and the event I added into a single event that is fired on element creation?

cc @gaearon

@gaearon
Copy link
Collaborator

gaearon commented Jun 30, 2016

I think so. Afaik this event already exists, check out #6800. You might want to tweak that code.

@hkal
Copy link
Contributor Author

hkal commented Jul 5, 2016

@gaearon You're right, looks like the event is already there. I removed the unnecessary code and updated the tests.

@jimfb Am I missing anything, or is this good?

@ghost ghost added the CLA Signed label Jul 12, 2016
@aweary
Copy link
Contributor

aweary commented Aug 12, 2016

getPossibleStandardName: __DEV__ ? {autofocus: 'autoFocus'} : null,

@hkal the values in getPossibleStandardName are injected in DOMProperty using HTMLDOMPropertyConfig.DOMAttributeNames. Could you move this into that object instead so it's injected like the other values are? I think this can be merged after that change, as far as I can see.

@aweary
Copy link
Contributor

aweary commented Sep 1, 2016

@hkal ping! Would you by chance have any free time soon to make this small change? I'd like to get this in soon. If not, no worries, I can get #7471 in 👍

@ghost ghost added the CLA Signed label Sep 1, 2016
@hkal
Copy link
Contributor Author

hkal commented Sep 1, 2016

@aweary my bad. Somehow I missed these notifications. Updated the pull request, let me know if anything else needs changing.

@aweary aweary self-assigned this Sep 1, 2016
@ghost ghost added the CLA Signed label Sep 1, 2016
@aweary
Copy link
Contributor

aweary commented Sep 3, 2016

Thanks @hkal, looks good to me 👍

@aweary aweary added this to the 15-next milestone Sep 3, 2016
@aweary aweary merged commit 6a525fd into facebook:master Sep 3, 2016
@ghost ghost added the CLA Signed label Sep 3, 2016
@zpao
Copy link
Member

zpao commented Sep 8, 2016

I'm actually going to revert this - it actually has more impact than just the warning and changes how autoFocus handling will behave. I can't demonstrate it in jsfiddle because frames and focus don't play nicely. But just take an example and render 2 inputs with autoFocus={true}. 15.x will consistently focus the 2nd. After this change the first will get focused (in Chrome) and we're otherwise subject to whatever the browser decides to do when nodes are updated or removed. That's not to say we should necessarily be handling this ourselves, but for the time being we shouldn't change it.

When we get to removing the whitelist we'll have to deal with that side of things. For now, if we want this to work, we need to handle this without adding the property to the whitelist as we don't want it to end up in the DOM.

@zpao zpao removed this from the 15-next milestone Sep 8, 2016
@aweary
Copy link
Contributor

aweary commented Sep 8, 2016

Thanks for clarifying @zpao, I had tested that autoFocus still worked before merging but didn't notice the order may have been inconsistent.

@hkal
Copy link
Contributor Author

hkal commented Sep 8, 2016

Thanks for explaining the issue, @zpao. Didn't even think to test that case.

@aweary I'm pretty confident we can still get the warning without any unintentional side affects if we go back to pre-defining the autofocus property in getPossibleStandardName. Aside from attribute injection, the only call to it is for producing warnings.

@aweary
Copy link
Contributor

aweary commented Sep 9, 2016

edit: see #3248 for discussion

acdlite pushed a commit to acdlite/react that referenced this pull request Sep 9, 2016
@hkal hkal deleted the autofocus-warning branch September 10, 2016 17:46
This pull request was closed.
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.

6 participants