-
Notifications
You must be signed in to change notification settings - Fork 50.5k
Address issues where ID of nodeName causes internal errors in React #10076
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,13 +34,11 @@ var supportedInputTypes: {[key: string]: true | void} = { | |
| }; | ||
|
|
||
| function isTextInputElement(elem: ?HTMLElement): boolean { | ||
| var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase(); | ||
|
|
||
| if (nodeName === 'input') { | ||
| if (elem instanceof HTMLInputElement) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't work when these nodes are rendered into another iframe. It's not a super common use case but a bigger discussion if we should stop supporting that.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Woah: iframe.contentWindow.window.HTMLInputElement instanceof HTMLInputElement // falseToday I learned....
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems like we could at least get some test coverage for this. I'll dig into that too. Though, if we don't have any coverage for it presently, I wonder if it's just a can of worms in JSDOM.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How much slower would it be to do something like: That gets us around working with the DOM. |
||
| return !!supportedInputTypes[((elem: any): HTMLInputElement).type]; | ||
| } | ||
|
|
||
| if (nodeName === 'textarea') { | ||
| if (elem instanceof HTMLTextAreaElement) { | ||
| return true; | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sebmarkbage this is the only downside I see to calling the
nodeNamegetter. Occasionally this value is the window. That's because the target instance falls back to the window when it can't find a target instance:https://github.com/facebook/react/blob/master/src/renderers/dom/shared/eventPlugins/ChangeEventPlugin.js#L149
I can't help but wonder if this could be
document.bodyinstead of window.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A good example of this is if you throw a breakpoint in this function and click anywhere on the page other than the target input.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry. To clarify: calling
nodeNameGetteronwindowraises an exception.