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

Warn against custom non-lowercase attributes #10699

Merged
merged 3 commits into from Sep 13, 2017

Conversation

Projects
None yet
5 participants
@gaearon
Member

gaearon commented Sep 13, 2017

Fixes #10590.

const e = await render(<div data-fooBar="true" />);
expect(e.getAttribute('data-fooBar')).toBe('true');
const e = await render(<div data-fooBar="true" />, 1);
expect(e.getAttribute('data-foobar')).toBe('true');

This comment has been minimized.

@gaearon

gaearon Sep 13, 2017

Member

Changing these calls wasn't essential but I figured I'd emphasize they are normalized by the browser anyway.

@gaearon

gaearon Sep 13, 2017

Member

Changing these calls wasn't essential but I figured I'd emphasize they are normalized by the browser anyway.

const e = await render(<div data-fooBar={true} />);
expect(e.getAttribute('data-fooBar')).toBe('true');
const e = await render(<div data-foobar={true} />);
expect(e.getAttribute('data-foobar')).toBe('true');

This comment has been minimized.

@gaearon

gaearon Sep 13, 2017

Member

These tests were not specifically about casing so I fixed them.

@gaearon

gaearon Sep 13, 2017

Member

These tests were not specifically about casing so I fixed them.

var rARIA = new RegExp('^(aria)-[' + DOMProperty.ATTRIBUTE_NAME_CHAR + ']*$');
var rARIACamel = new RegExp(
'^(aria)[A-Z][' + DOMProperty.ATTRIBUTE_NAME_CHAR + ']*$',
);

This comment has been minimized.

@gaearon

gaearon Sep 13, 2017

Member

Copy pasta from ARIA hook. Catches more cases which ensures we don't fire two warnings instead of one.

@gaearon

gaearon Sep 13, 2017

Member

Copy pasta from ARIA hook. Catches more cases which ensures we don't fire two warnings instead of one.

@gaearon gaearon requested review from sebmarkbage, nhunzaker and flarnie Sep 13, 2017

@gaearon gaearon added this to the 16.0 milestone Sep 13, 2017

@nhunzaker

Looks good, but I think this warning is going to require some community education. We need to broadly communicate what pitfalls we're protecting against.

@@ -701,23 +701,23 @@
## `as` (on `<div>`)
| Test Case | Flags | Result |
| --- | --- | --- |
| `as=(string)`| (changed)| `"a string"` |
| `as=(string)`| (initial)| `<empty string>` |

This comment has been minimized.

@gaearon

gaearon Sep 13, 2017

Member

This is an unrelated change, and seems like Chrome version difference. Setting <link as="whatever"> doesn't return "whatever" from link.as property anymore. But it works with valid values like "audio".

@gaearon

gaearon Sep 13, 2017

Member

This is an unrelated change, and seems like Chrome version difference. Setting <link as="whatever"> doesn't return "whatever" from link.as property anymore. But it works with valid values like "audio".

@gaearon

This comment has been minimized.

Show comment
Hide comment
@gaearon

gaearon Sep 13, 2017

Member

I agree but it’s also a bit hard to guess in advance what kind of things people would be using this for. So I’d wait until 16 and then look at these warnings again and maybe unify them more.

Member

gaearon commented Sep 13, 2017

I agree but it’s also a bit hard to guess in advance what kind of things people would be using this for. So I’d wait until 16 and then look at these warnings again and maybe unify them more.

| `selectedIndex=(-1)`| (initial)| `<number: -1>` |
| `selectedIndex=(0)`| (initial)| `<number: -1>` |
| `selectedIndex=(integer)`| (initial)| `<number: -1>` |
| `selectedIndex=(string)`| (initial, warning)| `<number: -1>` |

This comment has been minimized.

@sebmarkbage

sebmarkbage Sep 13, 2017

Member

I love that we finally got a nice warning on these for free.

@sebmarkbage

sebmarkbage Sep 13, 2017

Member

I love that we finally got a nice warning on these for free.

This comment has been minimized.

@sebmarkbage

sebmarkbage Sep 13, 2017

Member

Although I guess this will just make people try selectedindex instead. 😕

@sebmarkbage

sebmarkbage Sep 13, 2017

Member

Although I guess this will just make people try selectedindex instead. 😕

@gaearon gaearon merged commit c99bad9 into facebook:master Sep 13, 2017

1 check passed

ci/circleci Your tests passed on CircleCI!
Details

@gaearon gaearon deleted the gaearon:unknown-warn branch Sep 13, 2017

@bvaughn bvaughn referenced this pull request Sep 14, 2017

Closed

React 16 RC #10294

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