Merge pull request #10 from rwldrn/t970

Fixed ctor to throw friendlier exception on invalid media selectors [#970]
This commit is contained in:
Jon Buckley 2012-03-16 10:53:35 -07:00
Родитель 4cb0ccff26 2df06202e9
Коммит c7754eb845
2 изменённых файлов: 16 добавлений и 0 удалений

Просмотреть файл

@ -202,6 +202,12 @@
// Check if entity is a valid string id // Check if entity is a valid string id
matches = rIdExp.exec( entity ); matches = rIdExp.exec( entity );
try {
document.querySelector( entity );
} catch(e) {
throw new Error( "Popcorn.js Error: Invalid media element selector: " + entity );
}
// Get media element by id or object reference // Get media element by id or object reference
this.media = matches && matches.length && matches[ 2 ] ? this.media = matches && matches.length && matches[ 2 ] ?
document.getElementById( matches[ 2 ] ) : document.getElementById( matches[ 2 ] ) :

Просмотреть файл

@ -703,6 +703,16 @@ test( "Instance", function() {
}); });
test( "Bogus Selector", 1, function() {
try {
Popcorn( "#[object HTMLDivElement]" );
ok(false, "Should not fail silently" );
} catch(e) {
ok( true, "Exception raised on bogus selector: " + e.message );
}
});
module( "Popcorn Static" ); module( "Popcorn Static" );
test( "Popcorn.[addTrackEvent | removeTrackEvent].ref()", function() { test( "Popcorn.[addTrackEvent | removeTrackEvent].ref()", function() {