Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,10 @@ class YouTubePlayer extends EventEmitter {
constructor (element, opts) {
super()

const elem = typeof element === 'string'
this._elem = typeof element === 'string'
? document.querySelector(element)
: element

if (elem.id) {
this._id = elem.id // use existing element id
} else {
this._id = elem.id = 'ytplayer-' + Math.random().toString(16).slice(2, 8)
}

this._opts = Object.assign({
width: 640,
height: 360,
Expand Down Expand Up @@ -230,7 +224,7 @@ class YouTubePlayer extends EventEmitter {

this.videoId = null

this._id = null
this._elem = null
this._opts = null
this._api = null
this._player = null
Expand Down Expand Up @@ -301,7 +295,7 @@ class YouTubePlayer extends EventEmitter {

const opts = this._opts

this._player = new this._api.Player(this._id, {
this._player = new this._api.Player(this._elem, {
width: opts.width,
height: opts.height,
videoId: videoId,
Expand Down