-
Notifications
You must be signed in to change notification settings - Fork 47.2k
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 support for "invalid" event within Form elements #5187
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 |
---|---|---|
|
@@ -414,6 +414,17 @@ function trapBubbledEventsLocal() { | |
), | ||
]; | ||
break; | ||
case 'input': | ||
case 'select': | ||
case 'textarea': | ||
inst._wrapperState.listeners = [ | ||
ReactBrowserEventEmitter.trapBubbledEvent( | ||
EventConstants.topLevelTypes.topInvalid, | ||
'invalid', | ||
node | ||
), | ||
]; | ||
break; | ||
} | ||
} | ||
|
||
|
@@ -557,15 +568,13 @@ ReactDOMComponent.Mixin = { | |
case 'form': | ||
case 'video': | ||
case 'audio': | ||
this._wrapperState = { | ||
listeners: null, | ||
}; | ||
transaction.getReactMountReady().enqueue(trapBubbledEventsLocal, this); | ||
this._setupTrapBubbledEventsLocal(transaction); | ||
break; | ||
case 'button': | ||
props = ReactDOMButton.getNativeProps(this, props, nativeParent); | ||
break; | ||
case 'input': | ||
this._setupTrapBubbledEventsLocal(transaction); | ||
ReactDOMInput.mountWrapper(this, props, nativeParent); | ||
props = ReactDOMInput.getNativeProps(this, props); | ||
break; | ||
|
@@ -574,10 +583,12 @@ ReactDOMComponent.Mixin = { | |
props = ReactDOMOption.getNativeProps(this, props); | ||
break; | ||
case 'select': | ||
this._setupTrapBubbledEventsLocal(transaction); | ||
ReactDOMSelect.mountWrapper(this, props, nativeParent); | ||
props = ReactDOMSelect.getNativeProps(this, props); | ||
break; | ||
case 'textarea': | ||
this._setupTrapBubbledEventsLocal(transaction); | ||
ReactDOMTextarea.mountWrapper(this, props, nativeParent); | ||
props = ReactDOMTextarea.getNativeProps(this, props); | ||
break; | ||
|
@@ -686,6 +697,19 @@ ReactDOMComponent.Mixin = { | |
return mountImage; | ||
}, | ||
|
||
/** | ||
* Setup this component to trap non-bubbling events locally | ||
* | ||
* @private | ||
* @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction | ||
*/ | ||
_setupTrapBubbledEventsLocal: function(transaction) { | ||
this._wrapperState = { | ||
listeners: null, | ||
}; | ||
transaction.getReactMountReady().enqueue(trapBubbledEventsLocal, this); | ||
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. The 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. @spicyj Makes sense - probably worth raising a separate issue for this as this PR is now merged 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. I know it's merged. I was hoping that one of you would want to post a PR to fix it but I did it myself in #5213. 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. Cool - thank you! |
||
}, | ||
|
||
/** | ||
* Creates markup for the open tag and all attributes. | ||
* | ||
|
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.
I'm not sure if this description suffices but I didn't know how else to describe what it does!