зеркало из https://github.com/mozilla/popcorn-js.git
Merge pull request #10 from rwldrn/t970
Fixed ctor to throw friendlier exception on invalid media selectors [#970]
This commit is contained in:
Коммит
c7754eb845
|
@ -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() {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче