frankyghost / projekktor

The Free Web Video Player
194 stars 75 forks source link

Valid special characters (like hyphens) in the element id break the code #15

Closed sattes-faction closed 10 years ago

sattes-faction commented 10 years ago

The original issue I had was the following:

If I'm having a video element with a id containing a hyphen AND limiting projekktor to flash the loading spinner won't disappear after the video started:

    <video id="vid-1" width="560" height="315" controls>
      <source src="test.mp4" type="video/mp4">
    </video>

and providing ['browser','flash'] as platform limitation.

If I remove the hyphen, it works.

Basically projekktor fails on different lines if the id contains unusual characters. The HTML5 definition does not limit the characters for an id anymore (see http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html#the-id-attribute), so you could use whatever the charset offers.

So if some provides a - according to the specs - valid id like <p id="video♥"> <p id="video[test]"> it breaks projekktor, too.

I did not look into this any further but I guess it's because of auto-generating variable names out of the provided id and everything that's not a valid character for a JavaScript variable may cause problems here.

rwlodkowski commented 10 years ago

You're perfectly right. That's because charter '-' is invalid for JavaScript identifiers. http://mathiasbynens.be/notes/javascript-identifiers

Thanks for pointing that out. I think we should warn about that limitation in documentation.

Though I'm afraid it can't be fixed in any reasonable way.