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 MediaError #3562

Closed
wants to merge 4 commits into from
Closed

Conversation

misteroneill
Copy link
Member

We discovered that attempting to construct a video.js MediaError object would fail to properly copy a native MediaError object due to the code property being non-enumerable. Additionally, there were no tests for this module.

This is a re-opening of #3560 against stable.

Specific Changes proposed

  • Fix construction of video.js MediaError objects from native MediaError objects by manually assigning the code property.
  • Allow the video.js MediaError object to be redundantly constructed, such that if it is called with a video.js MediaError object, it simply returns the same object. This removes the need for two code forks found elsewhere in the code.

Requirements Checklist

  • Feature implemented / Bug fixed
  • Reviewed by Two Core Contributors

@gkatsev
Copy link
Member

gkatsev commented Aug 23, 2016

For future reference, you can now change the base of a PR without opening a new one: https://github.com/blog/2224-change-the-base-branch-of-a-pull-request

@misteroneill
Copy link
Member Author

Mind: blown! I've been wanting that feature for years.

@misteroneill misteroneill added the needs: LGTM Needs one or more additional approvals label Aug 23, 2016
if (typeof code === 'number') {
this.code = code;
} else if (typeof code === 'string') {
function MediaError(value) {
Copy link
Contributor

Choose a reason for hiding this comment

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

should this use the es6 class syntax, and be a constructor?

Copy link
Member Author

Choose a reason for hiding this comment

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

I mean, it could, but I'd prefer not needing to go through another code review if it can be avoided.

@brandonocasey
Copy link
Contributor

LGTM other than my comment on es6 class syntax

@misteroneill misteroneill added the patch This PR can be added to a patch release. label Aug 23, 2016
@gkatsev gkatsev added confirmed and removed needs: LGTM Needs one or more additional approvals labels Aug 24, 2016
gkatsev pushed a commit to gkatsev/video.js that referenced this pull request Aug 24, 2016
const createNativeMediaError = (code, message) => {
const err = Object.create(window.MediaError);

Object.defineProperty(err, 'code', {value: code});
Copy link
Member

Choose a reason for hiding this comment

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

this fails in IE8

@gkatsev
Copy link
Member

gkatsev commented Aug 24, 2016

Merged to stable, closing.

@gkatsev gkatsev closed this Aug 24, 2016
@misteroneill misteroneill deleted the fix-media-error branch August 24, 2016 22:57
helenjer pushed a commit to helenjer/video.js that referenced this pull request Sep 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed patch This PR can be added to a patch release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants