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

Patch bad DOM: <img fallbackImage= ...> #29

Closed
wants to merge 1 commit into from

Conversation

mheiber
Copy link

@mheiber mheiber commented Aug 4, 2016

No description provided.

@conorhastings
Copy link
Contributor

@mheiber do you have a reproducable case? this shouldn't be happening in any current version of react.

Something similar to this should go in at some point but I need to think more about whether or not we want to be more aggressive than this

@mheiber
Copy link
Author

mheiber commented Aug 7, 2016

@conorhastings thanks for following up. I can send a screenshot tomorrow, and this isn't a blocker.

@conorhastings
Copy link
Contributor

@mheiber thanks, no rush, running code would be preferable if possible, you can use https://esnextb.in/ with gists to access es6 imports etc...

@mheiber
Copy link
Author

mheiber commented Aug 8, 2016

@conorhastings here's an example.

Source code:

screen shot 2016-08-08 at 9 23 05 am

Warning message in the console:

screen shot 2016-08-08 at 9 21 43 am

These warnings go away when I make the change in this PR.

React dev tools:

screen shot 2016-08-08 at 9 22 13 am

@conorhastings
Copy link
Contributor

conorhastings commented Aug 8, 2016

@mheiber coool cool, what I would expect, doesn't appear to be getting into the actual dom just the virtual dom, I'll think about how to handle this some more and try to come to a conclusion this week if we should just merge this or go in another direction.

@mheiber
Copy link
Author

mheiber commented Aug 8, 2016

relevant React issue:

facebook/react#6800

I added a comment on that issue asking what the best practice is.

And you're right that the invalid props aren't making it to the actual DOM:

screen shot 2016-08-08 at 1 55 09 pm

@conorhastings
Copy link
Contributor

conorhastings commented Aug 8, 2016

@mheiber yup I'm aware of the react issue, there's ongoing debate over the best practice. https://twitter.com/natebirdman/status/759902308993937409

@mheiber
Copy link
Author

mheiber commented Aug 11, 2016

I'm thinking (based on discussion in the React issue) that deleteing the keys is better than assigning null.

@conorhastings
Copy link
Contributor

@mheiber
Copy link
Author

mheiber commented Aug 12, 2016

@conorhastings that's why I want to avoid delete, but there doesn't seem to be a good option. On the React issue, people recommended explicitly assigning all properties we want, but <img> actually has a TON of HTML attributes and it would be crazy to assign them all.

The warning they added to React is a mistake, IMO.

@conorhastings
Copy link
Contributor

@mheiber I think the warning makes sense, as in order to properly support web components they need to make all props pass through to the DOM. It follows the long term react pattern of giving warnings for breaking changes before breaking things, and only appears in development and not production which is relatively pragmatic.

Currently the whitelist react is using is also relatively unmaintainable as html properties change.

I'd prefer not to go with delete so I'm going to mull over other other potential options before deciding what to do here.

@conorhastings
Copy link
Contributor

@mheiber I think I'm going to go with this solution https://github.com/socialtables/react-image-fallback/pull/30/files as it will also prevent props that are spread in by consumers of the module and not just ones this component is directly responsible for.

@conorhastings conorhastings deleted the patch-img-attributes branch August 12, 2016 20:06
@mheiber
Copy link
Author

mheiber commented Aug 16, 2016

@conorhastings nice solution. I like the use of the html-attributes module much better than listing out all the possible attributes for an <img> tag.

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.

2 participants