-
Notifications
You must be signed in to change notification settings - Fork 47.5k
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
Support onLoad and onError on <link> #11825
Changes from 1 commit
e07c7f1
a8b8a8c
f92bac0
cb09630
e5604bf
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 |
---|---|---|
|
@@ -484,6 +484,7 @@ export function setInitialProperties( | |
break; | ||
case 'img': | ||
case 'image': | ||
case 'link': | ||
trapBubbledEvent('topError', 'error', domElement); | ||
trapBubbledEvent('topLoad', 'load', domElement); | ||
props = rawProps; | ||
|
@@ -858,6 +859,7 @@ export function diffHydratedProperties( | |
break; | ||
case 'img': | ||
case 'image': | ||
case 'link': | ||
trapBubbledEvent('topError', 'error', domElement); | ||
trapBubbledEvent('topLoad', 'load', domElement); | ||
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. For some background: I imagine we'll hit this again in the future as new HTML elements support onLoad/onError (though that's probably rare). As far as I understand it, we need to do this eager attachment because <div onLoad={() => alert('load!')>
<img src="image.jpg" />
</div> I sort of wonder if we should just respect the existing DOM behavior and avoid needing to eagerly attach these listeners. I'll write up an RFC for it! |
||
break; | ||
|
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.
Can you use
jest.fn()
instead of console.log? I know other tests use console, but it avoids needing the__DEV__
flag. More or less:Also, could you make the
load
anderror
event separate tests?