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

fix: better evented validation and error messages #6982

Merged
merged 3 commits into from
Jan 21, 2021

Conversation

brandonocasey
Copy link
Contributor

Our current error messages and validation are not enough as some errors can still seek through. I improved our error handling and reporting in many places and will make code comments to show why a change was made below. Originally this was a part of #6967

@@ -61,33 +62,76 @@ QUnit.test('evented() with custom element', function(assert) {
);
});

QUnit.test('trigger() errors', function(assert) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We never had a test for this before (since we didn't have an errors). I added it.

@brandonocasey brandonocasey added the needs: LGTM Needs one or more additional approvals label Dec 7, 2020
src/js/mixins/evented.js Show resolved Hide resolved
src/js/mixins/evented.js Show resolved Hide resolved
src/js/mixins/evented.js Show resolved Hide resolved
src/js/mixins/evented.js Show resolved Hide resolved
src/js/mixins/evented.js Show resolved Hide resolved
@brandonocasey brandonocasey force-pushed the fix/better-evented-validation branch from b3bba8a to 52e12b8 Compare January 21, 2021 21:06
@gkatsev gkatsev merged commit ffb690a into main Jan 21, 2021
@gkatsev gkatsev deleted the fix/better-evented-validation branch January 21, 2021 22:00
gkatsev added a commit that referenced this pull request Jan 26, 2021
Follow up from #6982. We previously threw an error but we've seen it
happen unexpectedly. Instead, we should log an error.

Here, if we have a `log` object on the current object, we should use it,
otherwise, we use a default `log` object.
gkatsev added a commit that referenced this pull request Jan 26, 2021
Follow up from #6982. We previously threw an error, but we've seen it
happen unexpectedly. Instead, we should log an error.
We will still throw an error if the event is undefined or null.

Here, if we have a `log` object on the current object, we should use it,
otherwise, we use a default `log` object.
@thijstriemstra
Copy link
Contributor

thijstriemstra commented Feb 5, 2021

This broke something in my plugin (using video.js 7.11.4). Investigating..

Error: Invalid target for null#on; must be a DOM node or evented object.
	    at validateTarget (node_modules/video.js/dist/video.js:2628:13)
	    at normalizeListenArgs (node_modules/video.js/dist/video.js:2721:5)
	    at t.on (node_modules/video.js/dist/video.js:2799:34)
	    at new Component (node_modules/video.js/dist/video.js:3446:14)
	    at t.<anonymous> (dist/commons.js:8:23621)
	    at new t (dist/commons.js:8:23848)
	    at UserContext.<anonymous> (dist/commons.js:20:34737)
	    at <Jasmine>

@gkatsev
Copy link
Member

gkatsev commented Feb 16, 2021

In 7.11.3, we had it throw in all error cases, in 7.11.4 we only throw in a few cases #7067.
Can you share a snippet of you using the event system? We definitely didn't mean to break anyone, and we probably would want to change it never throw again. I guess that's the risk of these changes. Would just be nice to know exactly what you're doing.

@thijstriemstra
Copy link
Contributor

@gkatsev it actually uncovered an issue in my tests: there was no player passed into constructor of custom component. So this is a good change for video.js so far.

I fixed it here: collab-project/videojs-record@493440b#diff-fd3e579b7fcc86745372fdfc089275daa8bc05c106d2ae363004114511d04481

@gkatsev
Copy link
Member

gkatsev commented Feb 16, 2021

@thijstriemstra ah, cool! So, no further action needed on our end right now?

@thijstriemstra
Copy link
Contributor

nope!

@misteroneill misteroneill removed the needs: LGTM Needs one or more additional approvals label May 23, 2023
edirub pushed a commit to edirub/video.js that referenced this pull request Jun 8, 2023
edirub pushed a commit to edirub/video.js that referenced this pull request Jun 8, 2023
Follow up from videojs#6982. We previously threw an error, but we've seen it
happen unexpectedly. Instead, we should log an error.
We will still throw an error if the event is undefined or null.

Here, if we have a `log` object on the current object, we should use it,
otherwise, we use a default `log` object.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants