diff options
author | Tobias Reich <tobias.reich.ich@gmail.com> | 2019-02-14 13:16:10 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-14 13:16:10 +0100 |
commit | c634d3696e625237926e339f5ffe2ef9b8789804 (patch) | |
tree | 4391400732a3385dccda90b8289c0ea745a64f2f | |
parent | 0189e90fce151a94a47d0f3f7bbbc8290c6ad4cd (diff) | |
download | plyr-c634d3696e625237926e339f5ffe2ef9b8789804.tar.lz plyr-c634d3696e625237926e339f5ffe2ef9b8789804.tar.xz plyr-c634d3696e625237926e339f5ffe2ef9b8789804.zip |
Remove NodeList example
I've removed the NodeList example because it's confusing. Only the first element of a NodeList will be used and this is usually not what you want. I've instead replaced it with a `querySelector` and map example. It's related to: https://github.com/sampotts/plyr/issues/801
I know that there was a note, pointing out that the first element will be used, but be honest: Everybody is just scanning the examples for code and doing copy paste :D
-rw-r--r-- | readme.md | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -229,7 +229,6 @@ You can specify a range of arguments for the constructor to use: - A CSS string selector that's compatible with [`querySelector`](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector) - A [`HTMLElement`](https://developer.mozilla.org/en/docs/Web/API/HTMLElement) -- A [`NodeList`](https://developer.mozilla.org/en-US/docs/Web/API/NodeList) - A [jQuery](https://jquery.com) object _Note_: If a `NodeList`, `Array`, or jQuery object are passed, the first element will be used for setup. To setup multiple players, see [setting up multiple players](#setting-up-multiple-players) below. @@ -248,13 +247,15 @@ Passing a [HTMLElement](https://developer.mozilla.org/en/docs/Web/API/HTMLElemen const player = new Plyr(document.getElementById('player')); ``` -Passing a [NodeList](https://developer.mozilla.org/en-US/docs/Web/API/NodeList) (see note below): +```javascript +const player = new Plyr(document.querySelector('#player')); +``` ```javascript -const player = new Plyr(document.querySelectorAll('.js-player')); +const instances = [...document.querySelectorAll('.player')].map((elem) => new Plyr(elem)) ``` -The NodeList, HTMLElement or string selector can be the target `<video>`, `<audio>`, or `<div>` wrapper for embeds. +The HTMLElement or string selector can be the target `<video>`, `<audio>`, or `<div>` wrapper for embeds. ##### Setting up multiple players |