Skip to content

Commit 5d72dc8

Browse files
committed
fix(embed all): Changed selector from attribute name to class name
1 parent e4a3fc2 commit 5d72dc8

6 files changed

Lines changed: 11 additions & 21 deletions

File tree

demo/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
<h1>Loading embed.js in a block</h1>
3434

35-
<div id="block">
35+
<div id="block" class="block">
3636
**Pulchritudines** nocere, :heart: tanquam ~~talis~~ hibrida.A falsis, brodium :+1: salvus gabalium.Nunquam
3737
promissio @(iit roorkee) http://iitr.ac.in caesium.Cum rumor https://twitter.com/IGN/status/652941146054881281
3838
peregrinationes https://www.flickr.com/photos/xdjio/226228060/, omnes ususes http://www.sample-videos.com/video/mp4/240/big_buck_bunny_240p_50mb.mp4 https://soundcloud.com/the-bugle/bugle-179-playas-gon-play
@@ -48,7 +48,7 @@ <h1>Loading embed.js in a block</h1>
4848
```
4949
Flavum, ferox http://open.spotify.com/track/4th1RQAelzqgY7wL53UGQt torquiss vix aperto de http://plnkr.co/edit/AK732k bi-color, http://www.iitr.ac.in/Main/assets/images/topold.jpg audax nixus.Pol, alter devatio!Crescere aliquando ducunt ad noster lixa. :smile: :P https://www.youtube.com/watch?v=bQRLVxZHKPs http://www.liveleak.com/view?i=42a_1426999994 https://gist.github.com/jeremiahlee/1748966 https://gist.github.com/thomasmb/7132686 https://twitter.com/ProductHunt/status/652826210666418176/photo/1 http://www.ted.com/talks/monica_lewinsky_the_price_of_shame http://www.dailymotion.com/video/x2k8un2_2015-wc-nz-vs-wi-holder-reacts-on-guptills-237_sport https://vine.co/v/bjHh0zHdgZT https://vimeo.com/119199079 http://www.w3schools.com/html/horse.mp3
5050
</div>
51-
<div id="block2">
51+
<div id="block2" class="block">
5252
Cur rumor nocere?Emeritis adelphis satis perderes domina est.Gloss cadunt in bi-color brema!
5353
@(IIT Roorkee) Bi-color habitio virtualiter imitaris amicitia est.Teres tatas ducunt ad racana.Genetrixs
5454
prarere in
@@ -85,7 +85,7 @@ <h1>Loading embed.js in a block</h1>
8585
})
8686

8787

88-
// ejs.applyEmbedJS();
88+
// ejs.applyEmbedJS("block");
8989
</script>
9090

9191
</body>

dist/embed.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/embed.js

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/embed.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/js/embed.es6

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,12 @@ const helper = require('./modules/video/helper.es6');
200200

201201
let ejs = {
202202
instances: [],
203-
elements: utils.getElementsByAttributeName('data-embed-js'),
203+
elements: [],
204204
setOptions: function(options) {
205205
globalOptions = utils.deepExtend(defaultOptions, options)
206206
},
207-
applyEmbedJS: function() {
207+
applyEmbedJS: function(className) {
208+
this.elements = document.getElementsByClassName(className)
208209
for (let i = 0; i < this.elements.length; i++) {
209210
let option = {
210211
element: this.elements[i]

src/js/modules/utils.es6

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -132,18 +132,6 @@ var utils = {
132132
}
133133
},
134134

135-
getElementsByAttributeName: (attribute) => {
136-
let matchingElements = [];
137-
let allElements = document.getElementsByTagName('*');
138-
for (let i = 0, n = allElements.length; i < n; i++) {
139-
if (allElements[i].getAttribute(attribute) !== null) {
140-
// Element exists with attribute. Add to array.
141-
matchingElements.push(allElements[i]);
142-
}
143-
}
144-
return matchingElements;
145-
},
146-
147135
/**
148136
* Returns a cloned object
149137
* @param {object} obj

0 commit comments

Comments
 (0)