Skip to content

Commit

Permalink
selector support element type
Browse files Browse the repository at this point in the history
  • Loading branch information
DIYgod committed Jan 19, 2018
1 parent 91a362c commit 14c0d09
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion index.player.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ function PearPlayer(selector, token, opts) {
if (!(self instanceof PearPlayer)) return new PearPlayer(selector, token, opts);
if (typeof token === 'object') return PearPlayer(selector, '', token);
if (!opts) opts = {};
if (typeof selector !== 'string') throw new Error('video selector must be a string!');
if (typeof selector === 'string') {
self.video = document.querySelector(selector);
} else if (Object.prototype.toString.call(selector) === '[object HTMLVideoElement]') {
self.video = selector;
} else {
throw new Error('illegal video selector');
}
self.video = document.querySelector(selector);
opts.selector = selector;
opts.render = render;
Expand Down

0 comments on commit 14c0d09

Please sign in to comment.