Skip to content
This repository has been archived by the owner on Jun 29, 2018. It is now read-only.

Fixed event not triggered correctly. #457

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Fixed event not triggered correctly. #457

wants to merge 2 commits into from

Conversation

benjah1
Copy link

@benjah1 benjah1 commented Jul 21, 2015

  1. added logic ensure onFirstPlay -> onFirstPause -> onReady will be trigger.
  2. updated customEvent to latest syntax
  3. updated customEvent bubbles to true. Since some events may bind to different elements

This is for youtube stop working on Chrome on Jul 21.
It is fine on Firefox, so a Chrome update may break it.

1. added logic ensure onFirstPlay -> onFirstPause -> onReady will be trigger.
2. updated customEvent to latest syntax
3. updated customEvent bubbles to true. Since some events may bind to different elements.
@benjah1
Copy link
Author

benjah1 commented Jul 21, 2015

On popcorn.HTMLYouTubeVideoElement.unit.html
Before update: 28 fail.

After update,

  1. 7 fail (9, 24, 26, 27, 35, 36, 42)
  2. 5 fail (8, 26, 35, 41, 32)
  3. 7 fail (24, 25, 26, 27, 35, 41, 42)
    Tested on Chrome 43.0.2357.134 x64

@alidinani
Copy link

This is great for fixing chrome
However, CustomEvent doesn't exist in IE (well exists but doesnt work) :(

Edit: Fixed by adding a Polyfill for IE

@azmenak
Copy link

azmenak commented Jul 22, 2015

Which is here:

(function () {
      function CustomEvent ( event, params ) {
        params = params || { bubbles: false, cancelable: false, detail: undefined };
        var evt = document.createEvent( 'CustomEvent' );
        evt.initCustomEvent( event, params.bubbles, params.cancelable, params.detail );
        return evt;
      };

      CustomEvent.prototype = window.Event.prototype;
      window.CustomEvent = CustomEvent;
    })();

@benjah1
Copy link
Author

benjah1 commented Jul 22, 2015

Added the polyfill.
Tested on IE11.

Two concerns,

  1. It injects to global scope. But it is the same for MediaError as well.
  2. During the unit test, events fail to fire occasionally.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants